How to check for to extract only time from date time format

I have a string “8/25/2018 6:03:12 AM” i want to extract only the time along with AM/PM and i should check a condition weather extracted time value is between 12 AM to 5 AM.

1 Like

convert.ToDateTime(“8/25/2018 6:03:12 AM”).tostring(“hh:mm:ss tt”)

after extracting the time from the string i want to check a condition weather extracted time value is between 12 AM to 5 AM.

1 Like

Datetime supports >,<,= etc. So just give

if condition, convert.ToDateTime(“8/25/2018 6:03:12 AM”) > Today and convert.ToDateTime(“8/25/2018 6:03:12 AM”) > Today.AddHours(5)