How to convert a string to datetime and check if its more than 24 hours?

Dear Developers, i have files in FTP server with filenames as follows as an example 01-12-2021 02-04-23 (dd-MM-yyyy hh-mm-ss) …i want to check and download if the filename is more than 24 hours from the current time? really appreciate your kind help.

Hi @Yusuf_Rahmaniac

pls check my solution. If it help you, pls set as solution. :grinning:
convert-a-string-to-datetime.zip (2.3 KB)

TargetTime = System.DateTime.ParseExact(str1,“dd-MM-yyyy hh-mm-ss”,System.GloBalization.CultureInfo.InvariantCulture)

1 Like

Hi @Yusuf_Rahmaniac

Please see below inline screenshot. It’s almost same as @hz171168 .

Please mark @hz171168 post as solution :slight_smile:

Thank you.

2 Likes

well noted. it works great. thank you very much for your fast response and awesome answer.

well noted. it works great. thank you very much for your fast response.

hi i have tried the solution but it will only subtracts the time…but it does not take date into consideration. Really appreciate your kind assistance

Hi @Yusuf_Rahmaniac

Thanks for letting me know this.

Here is the solution,

DataType of TimeDiff is TimeSpan

image

Code:
DateTime_HourDiff.xaml (9.1 KB)

Kindly check/test the given solution and close the topic by marking the solving post as ‘solution’

Thank you.

2 Likes

thanks alot for very fast response…this works great… thanks alot again

1 Like

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