How to assign only time value to variable (Date time Variable) with AM/PM (without date)

How to assign an only time value to a variable (Date time Variable) with AM/PM (without date)

I want to compare my time value with other Eg Mytime_value=06:30:05 AM and should validate whether Mytime_value is greater than 12:00:00 AM and Less than 05:00:00 AM. so I am taking two Assign activity and assigning the time value to compare but it is taking with current date and not considering AM/PM please help me out


To read AM/PM, specify tt

DateTime.Now.ToString("hh:mm:ss tt")

bro iam able to read AM/PM but iwant to assign a time value in a assign activity with AM/PM to compare with another time value (and i dont want date value but by default it is taking date value also in assign activity )

bro idont want Current date time value ihave the time value already iwant to compare with other time value

so basically you want to check if the time in your excel is between 12am to 5am

is this correct?

i am guessing this is an extension to the post you had earlier and I used the same excel file from the last time.

We will continue ahead from where we just read the time from the date/time column and this time i used to expression given by @anil5

I simply used a if else activity to check if the time is in the given range i.e., 12am to 5pm if yes it will write a line saying “time in range” else “time out of range”

is this something what you were looking for?

Main (8).xaml (14.1 KB)

1 Like


Please follow a below snapshot,


I have Time column and I am assigning excel value to time variable.


yes correct bro but it is not working

what seems to be the error?

You can’t convert String to Time. Still i have the same error