Converting Date and time formats

Hi,

May I know how to reformat this date format 7/20/2020 8:00:00 to 20-07-2020 08:00? thank you very much.

Hi @Penganimation,

Some useful link

Regards,
Omkar P

Hi,
strvar="7/20/2020 8:00:00

use,
convert.ToDateTime(strvar).tostring("dd-mm-yyyy hh:mm)

@Penganimation

Check as below

Hope this helps

Thanks

thank you. Problem is i am reading these dates from a data table generated out of a excel sheet and it gives me an error when using this function mentioned in the link.

@Penganimation

Convert.toDateTime(row.item(“DATE”).ToString(“dd/MM/yyyy hh:mm”)

Try this and the assignment of variable should be string not a Integer

Check the type of the variable

Thanks

3 Likes

Thank you so much. Just to side track a bit, how to compare dates?

current date??

Yes I want to check if the date I am using is later than the current date and time or not.

Basically I want to run something based on predefined dates all the way to the current date and stop

@Penganimation

Place a IF Condition

convert.ToDateTime(row(“DateColumn”)).ToString(“dd/MM/yyyy”) = now.ToString(“dd/MM/yyyy”)

Hope this helps

Thanks

Hi,
used 1 string variable
strvar=system.DateTime.now.tostring("dd-mm-yyyy h:mm)

and Compare the both the string

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.