How to chek if 24h have ellapsed

hi, I have a string in the form of “23_02_2024 / 23:07:00” how too check in 24h have ellapsed from this time stamp?

1 Like

Are you looking for this?

or can you elaborate more on:

1 Like

Hi,

Can you try as the following sample?

Sequence1.xaml (7.4 KB)

dateTimeVar = DateTime.ParseExact(strDateTime,"dd_MM_yyyy / HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture)

then check

Now>dateTimeVar.AddHours(24)

Regards,

1 Like

HI @tomaz

Try this:

Output = If (DateTime.Now.Subtract(DateTime.ParseExact("23_02_2024 / 23:07:00", "dd_MM_yyyy / HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture)).TotalHours >= 24, "24 hours have elapsed.", "24 hours have not elapsed yet.")

Hope it helps!!

to check if 24 hours have elapsed from a given timestamp string "23_02_2024 / 23:07:00", you can use an Assign activity to parse the string to a DateTime object and then compare it with the current time.
Step 1:
Assign Activity: Create a DateTime variable parsedDate.
Code:  DateTime.ParseExact("23_02_2024 / 23:07:00", "dd_MM_yyyy / HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture)

Step2:
Assign Activity: Create a TimeSpan variable timeElapsed.

Code:   DateTime.Now - parsedDate

Step 3: 
If Activity: Use an If activity to compare timeElapsed.TotalHours with 24.

Condition:
timeElapsed.TotalHours >= 24

Then: Do what needs to be done if 24 hours have elapsed.
Else: Do what needs to be done if less than 24 hours have passed.
Ensure that you have the correct format and culture that matches your timestamp. If the format of the timestamp is different in your environment, you need to adjust the format in the ParseExact method accordingly.

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