Current time and end time are in the string format but need to convert it to date time format.
Current time is system date time where as the end date is taken from excel its in string format.
Used Convert.Todatetime but its showing in 06/10/2023 03:44:00.
Format getting as expected but the variable type is string need to convert to datetime.
How to do this please help. Extracted data - Copy.xlsx (8.1 KB)
Could you let us know what is the End Output that you require ? Are you storing this data in Excel and you want to represent it in the mentioned format ?
Do note that DateTime types is a Date type and it will inherently have no format or will have the one format in its DateTime type, and if we would require it to be in custom format, we convert it using .ToString() where the data type changes to String.
“MM/dd/yyyy HH:mm:ss” this is a datetime format
“MM/dd/yyyy hh:mm tt” this is a custom datetime format
You will only get “MM/dd/yyyy HH:mm:ss” this format in datetime variable. By using this variable, you will able to change into other custom formats like “MM/dd/yyyy hh:mm tt” but can only storable in a string variable.
When you work with date and time values, you store the date and time values in a DateTime variable. The DateTime variable stores the actual date and time data, not the format.
You can format the DateTime variable as a string using a custom format like “MM/dd/yyyy hh:mm tt” when you need to display or output it. The formatted result is a string, not a DateTime variable, and you store it in a string variable.