Date Compare Issue

Note that if taking out the time portion of the comparison, there are no three possibilities that need to be accounted for:

  1. Date is in the past
  2. Date is in the future
  3. Date is same as Today

Yes, and is relevant to the business case and its details

when date is
today morning: 09/09/2022 10:00 and in this shot we do have
today afternoon 09/09/2022 15:00

then check for the date without time part can be done when we are interested is it 09/09/2022

BUT when it is important to find out is it before the shot or not, then sure we need the time part as well

from OP we do see this requirement, so the time portion is not include.

Otherwise let the OP respond and give feedback on what is finally needed

1 Like

Any updates still not working

Application_Date(String) = “Sep, 10, 2022 10:00 AM”
Appli_Date = DateTime.ParseExact(Application_Date,“MMM,dd,yyyy”, System.Globalization.CultureInfo.InvariantCulture)

if Appli_Date > Not

Not getting correct result.
String not recognized as valid date time in PartExact line.

Have a Look at Screenshots from immediate Panel. Do Not ommit the time Portion when parsing the Date String an also include HH:mm tt

Changed the code like below still the same error
DateTime.ParseExact(Application_Date,“MMM,dd,yyyy HH:mm tt”, System.Globalization.CultureInfo.InvariantCulture)


"MMM, dd, yyyy HH:mm tt"
vs. your used format:
“MMM,dd,yyyy HH:mm tt”,

it ismportant also to keep the spaces

DateTime.ParseExact(DateString,"MMM, dd, yyyy hh:mm tt",System.Globalization.CultureInfo.InvariantCulture)

Space misssing in your code

Use the DateTime.CompareTo method.

Some conditions are getting passed based on your above suggestions but

Sep, 12, 2022 12:00 PM - Pass
Sep, 12, 2022 11:30 PM - Pass
Sep, 12, 2022 01:00 PM - Fail
Sep, 12, 2022 02:00 PM - Fail
Sep, 12, 2022 13:00 PM - Pass - How to convert to 24 hr format ?
String not recognized as valid date time - in ParseExact line

Looks like 01:00, 02:00 not working need to convert to 24 hr format how to convert this ?

Refer this Xmal File
Here using regex, the AM or PM will be removed
If the flow need to check date alone, time is not important, then use this flow
image
DateCompare.xaml (13.1 KB)

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