Check column date is less than or equal to specific date

Hi Team

I am getting current date-6 months and then converting it to dd-MMM-YY which is the required format in my excel coloumn.

str_date is a string variable in which I am getting a current date-6 months

Now I want to check in if condition like this and if true then hiighlight those cells

cdate(CurrentRow(“DOJ”)).ToString(“dd-MMM-yy”)<=CDate(str_date.ToString).ToString(“dd-MMM-yy”)

The above condition is highlighting incorrectly

Hi @Muralikrishna_Basani

If possible can you share the sample Input file.

Try this expression to Get the Current Date -6 Month

str_date  = DateTime.Now.AddMonth(-6).Tostring("dd-MMM-yy")
DOJ = DateTime.ParseExact(CurrentRow(“DOJ”)).ToString,("dd.MM.yyyy"),Globalization.CultureInfo.InvariantCulture).ToString(“dd-MMM-yy”)

dd.MM.yyyy" → Input format based on the excel file

Use If condition

DOJ <= str_date

Regards
Gokul

Hi @Muralikrishna_Basani ,

You are Comparing the Dates in it’s String format. We would need to keep the Dates in DateTime format for comparison between two dates.

In Your Case, Just try the below :

CDate(CurrentRow("DOJ").ToString)<=CDate(str_date.ToString)

Thank you bro!!, It worked

1 Like

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