Date comparison error _Panel

Hi all I am checking a condition where

nssd>=acm Below are the dates.

I should get True but here the bot is taking as false

nssd=02/01/2024 00:00:00
acm =01/19/2024 00:00:00
image

Hi @marina.dutta

What do you want to compare?
Are the below inputs?
nssd=02/01/2024 00:00:00
acm =01/19/2024 00:00:00

Regards

@vrdabberu

yes .compare two dates .with out time stamp

condition is nssd>=acm (whther True or false ). It should be true I believe as its nssd =feb and acm is in Jan

@marina.dutta

nssd=02/01/2024 00:00:00
acm =01/19/2024 00:00:00

the above are string inputs right?

Regards

Try this,

DateTime.ParseExact("02/01/2024 00:00:00", "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture) >= DateTime.ParseExact("01/19/2024 00:00:00", "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture)

Thanks,
Vinit Mhatre

Hi @marina.dutta

Try the below way:

Assign-> nssd = "02/01/2024 00:00:00"
Assign-> acm = "01/19/2024 00:00:00"
Assign-> str_nssd = DateTime.ParseExact(nssd, "MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture).ToString("MM")
Assign-> str_acm = DateTime.ParseExact(acm, "MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture).ToString("MM")

If
  nssd >= acm
Then
    Print TRUE
Else
    Print FALSE
End If

the variables in Assign are of DataType System.String.


Regards

@marina.dutta

DateTime.ParseExact(nssd,"MM/dd/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture) >= DateTime.ParseExact(acm,"MM/dd/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture)

@rlgandu

image

Hi @marina.dutta

Try this this will work.

or pass this in If

DateTime.ParseExact(nssd, "MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture).ToString("MM") >= DateTime.ParseExact(acm, "MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture).ToString("MM")

Regards

@vrdabberu

why we are using ("MM)

@marina.dutta

.ToString(“MM”) will take the months from the data and compare that. So, in nssd it is 02 i.e Febuary and in acm it is 01 i.e January since Feb is greater than Jan it will print true.

From the give string inputs I have taken the months and compared within If
Regards

@marina.dutta

For more information you can refer the below thread regarding DateTime. This will give you an idea on it.

Regards

@vrdabberu

i have taken both nssd and acm as DateTime type.

image

Hi @marina.dutta

Then in that case you can pass the below condition in If

nssd.ToString("MM")>=acm.ToString("MM")


Regards

@marina.dutta

Output Datatype is boolean

Output=DateTime.ParseExact(nssd.ToString, "MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture) >= DateTime.ParseExact(acm.ToString, "MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture)

@vrdabberu

Can I use nssd.Date.Tostring(“mm”)>=acm.date.tostring("mm)

@vrdabberu

I need to check the dates .Even if same month but dates are different it .

For example if acm = 02nd feb and nssd =19 th feb it should be true

Hi @marina.dutta

nssd.ToString("dd")>=acm.ToString("dd") And nssd.ToString("MM")>=acm.ToString("MM")

Regards

@marina.dutta

If you have different Formats of dates Please change to One Format and then check your condition.Please provide all your dateformats so that we will help you

@marina.dutta

you are comparing dates of two variables and months of two variables. This syntax should help you.

nssd.ToString("dd")>=acm.ToString("dd") And nssd.ToString("MM")>=acm.ToString("MM")

Regards