Hi, thank you for the suggestion. If a different input example was given without any date and just the time say for example an input string will be “17:00 PM”. Is it possible to be able to still use this time alone without any date and in this format and if its within the time range as shown above?
I have tried using DateTime.ParseExact(TestString, “hh:mm”, Globalization.CultureInfo.InvariantCulture)
From the input “17:30 PM” - I dropped the PM so used the above command without the tt inside the input string because it is already in a 24hour format. I kept receiving the error “Assign: String was not recognized as a valid DateTime.”
Is there a correct command I could be able to use using the 24 hour format for this original question?
Please check this…In this case, Datetime.parse will help you…
Please note , since I am in US , if I give dd/MM/yyyy format datetime.parse will thrown an error. So but if your country format/system time is dd/MM/yyyy you can use it as is.
Thank you - there will be no dates included as is just the time. That suggestion worked but unable to use it for the last part in the if statement where it then checks if the time is within the time range or not because it is in a string
I am confused now. what is your exact input values? Initially you said, it is “27/08/2021 4:30:00 PM”, “31/08/2021 11:00:00 AM” and then you said, "“17:00 PM”… So please clarify??
Yes that is right but then with this time input I need to check if it is within a time period -
For example an input is “17:00 PM” and I need to check if this time is within say 10:00 AM and 2:00 PM
So it would be put into an if else activity statement where it checks if 17:00 PM is within the time period or outside the time period. In one of the suggestions above it has a command in the if condition but because the input value is in a string type not datetime type so unable to use this input inside the if condition if that makes sense?