Check which entries in table have a timestamp older than a day

Hi, I have an Excel table with transactions that failed. Each row has a timestamp that was created with the “now”-function in one of the columns (header Timestamp). How can I go through the table and select the ones that are older than a day?
Thanks

Buddy @Jizh

Inside a for each row loop use a if condition like this

Datetime.Parseexact(row(“columnname”),“dd/MM/yyy”,system.Globalization.CultureInfo.InvariantCulture) <= Datetime.Parseexact(now.tostring(“dd/MM/yyyy”),“dd/MM/yyy”,system.Globalization.CultureInfo.InvariantCulture)

But i would like to know the timestamp format that you have or either you can change the format in the above string based on what you have

Cheers

1 Like

@Palaniyappan Thank you. The format is 08.05.2019 10:32. The thing is that I would always like to check for values that are older than one day (not only older than today but at least 24hours older).

Fine Buddy , here it is

Datetime.Parseexact(row(“columnname”),“dd.MM.yyyy hh:mm”,system.Globalization.CultureInfo.InvariantCulture) <= Datetime.Parseexact(now.AddHours(-24).ToString(“dd.MM.yyyy hh:mm”),“dd.MM.yyyy hh:mm”,system.Globalization.CultureInfo.InvariantCulture)

Cheers

1 Like

@Palaniyappan I tried the solution but it gives me the error that it can’t convert object to String. However if I convert row(“xyz”).ToString it gives me the error that the String was not recognized as a valid DateTime.

Buddy may i have a screensht at which activity we were facing the erro

1 Like

Wow that was fast :smiley: It will be with an Excel afterwards but I tested it isolated

Buddy it seems like a if condition that needs boolean as the outcome of the condition, but we didn’t have such we are getting only datetime type only buddy
Make some comparison with some operators like conditional operators

Cheers

Yes, it is only part of the condition visible. I used the one you gave me before.
Datetime.Parseexact(Timestamp,“dd.MM.yyyy hh:mm”,system.Globalization.CultureInfo.InvariantCulture) <= Datetime.Parseexact(now.AddHours(-24).ToString(“dd.MM.yyyy hh:mm”),“dd.MM.yyyy hh:mm”,system.Globalization.CultureInfo.InvariantCulture)

Kindly Place the cursor in the blue icon get the screenshot so that we canknow the error buddy

Uipath
The last part in German says that the Option Strict On doesn’t allow implicit conversions from Date to String

yah gotcha

the issue with the timestamp which is in datetime type, but the parameter must be passed as string so type as , the one we missed

Datetime.Parseexact(Timestamp.ToString,“dd.MM.yyyy hh:mm”,system.Globalization.CultureInfo.InvariantCulture) <= Datetime.Parseexact(now.AddHours(-24).ToString(“dd.MM.yyyy hh:mm”),“dd.MM.yyyy hh:mm”,system.Globalization.CultureInfo.InvariantCulture)

I tried but then during execution it gives an error:
System.FormatException: String was not recognized as a valid DateTime

The output of the string is the following:
“05/06/2019 16:34:58”

Aaah,I thought the string is in dd.MM.yyyy not dd/MM/yyyy

is dd/MM/yyyy is the format of timestamp variable buddy…?

if so change it as the same
Datetime.Parseexact(Timestamp. ToString ,“dd/MM/yyyy HH:mm:ss”,system.Globalization.CultureInfo.InvariantCulture) <= Datetime.Parseexact(now.AddHours(-24).ToString(“dd/MM/yyyy HH:mm:ss”),“dd/MM/yyyy HH:mm:ss”,system.Globalization.CultureInfo.InvariantCulture)

1 Like

Oh, I see it’s my bad. Alright, then. Thanks for your patience :slight_smile:

Is that working now

I still get the same message.

Buddy i made some changes in the last post did you try that

Aaah,I thought the string is in dd.MM.yyyy not dd/MM/yyyy

is dd/MM/yyyy is the format of timestamp variable buddy…?

if so change it as the same @Jizh
Datetime.Parseexact(Timestamp. ToString ,“dd/MM/yyyy HH:mm:ss”,system.Globalization.CultureInfo.InvariantCulture) <= Datetime.Parseexact(now.AddHours(-24).ToString(“dd/MM/yyyy HH:mm:ss”),“dd/MM/yyyy HH:mm:ss”,system.Globalization.CultureInfo.InvariantCulture)

1 Like

I will look at it tomorrow. Thanks a lot, those date conversions look pretty complicated to me :smile:

Buddy last try that work for sure i missed the seconds @Jizh
Lets do this

1 Like