hi all
im trying to make a process to read a column of dates, and then check if the date is within the last 3 months. how would i be able to do this?
thanks
hi all
im trying to make a process to read a column of dates, and then check if the date is within the last 3 months. how would i be able to do this?
thanks
Hi @Aaronlim,
Kindly follow the below steps.
DateTime.Parse(row(‘date’).ToString) > DateTime.Now.AddMonths(-3)
True
if the date falls within the last 3 months and otherwise False
.Happy Automation, If you find it useful mark it as a solution.
Warm Regards,
Ranjith Udayakumar
hi,
when i tried this, i got an error saying that the string was not recognised as a valid datetime.
the strings used are in column E and F in the pic below
Hi @Aaronlim,
Please mention the date format explicitly as like below. It will work.
DateTime.ParseExact(row(‘date’).ToString, “dd/MM/yyyy”,Nothing) > DateTime.Now.AddMonths(-3)
Warm Regards,
Ranjith Udayakumar
hi,
it works for most cells, but for those with 00:00:00 at the side, it throws an error and is not converted. is there a way around this?
the 00:00:00 was added to some of the cells after using read and write range from a csv file.
Hi @Aaronlim,
You can create a list of formats and then use it conversion like below.
formats= {"dd/MM/yyyy","dd/MM/yyyy hh:mm:ss"}
DateTime.ParseExact(row(‘date’).ToString,formats,new CultureInfo(“en-US”),DateTimeStyles.None) > DateTime.Now.AddMonths(-3)
Now it will pass.
Note: You should import the System.Globalization in the import panel.
works now, thanks so much for the help!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.