How to get previous date?

Getting previous date based on a format .

Date format sample : 210315 , that is YYMMDD. I want to check if date is a previous date

Current solution :>

sample_date.ToString.Trim.Split("-"c)(1).ToString <“yyMMdd”).ToString

But this will include date that are 2 days ago , I only want previous day date

Input : 210314 - True because today is 15 and previous day is 14
Input: 210313 - False since morethan 2 days already had passed this is not last day or previous day.

Any idea ? thanks.

u can use like this



Nived N

Happy Automation


As @NIVED_NAMBIAR has already indicated.

I have here a screenshot as a test :wink:


As an alternate you can try this too @AhmedKutraphali …shorter version of what @NIVED_NAMBIAR provided…


1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.