Hi All,
I have to Convert a excel cell value to particular date format.
Input: Fri Jan 20 00:00:00 2022
I need an output in this format(dd/MM/yyyy hh:mm:ss) 20/01/2022.
Please help me with this question.
Regards,
Manoj
Hi All,
I have to Convert a excel cell value to particular date format.
Input: Fri Jan 20 00:00:00 2022
I need an output in this format(dd/MM/yyyy hh:mm:ss) 20/01/2022.
Please help me with this question.
Regards,
Manoj
@indra thanks for your reply, But there is a weekday in input how can i manage that one.
Regards,
Manoj.
Hi @manojmanu.rpa
formattedDate = CDate(your_variable).ToString(“dddd, dd/MM/yyyy hh:mm:ss”)
This will output a string in the format: “Friday, 20/01/2022 00:00:00”
@indra @Shanmathi Consider this one as Input Fri Jan 20 00:00:00 2022 and the output need to come 20/01/2022 00:00:00, without weekday.
Thanks,
Manoj.
Try with this expression
DateTime.ParseExact(System.Text.RegularExpressions.Regex.Replace("Fri Jan 20 00:00:00 2022","^\S{3}\s",""),"MMM dd hh:mm:ss yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy hh:mm:ss")
Regards
Gokul
In addition to:
In general we would recommend to use ParseExact for converting the string into a dateTime
Afterwards we can reformat as needed
DateTime.ParseExact(YourInputString, YourFormat, System.Globalization.CultureInfo.InvariantCulture)
Format parts (in/out) are as:
Kindly note: Friday 20th Jan 2022 does not exist, it was a Thursday so parsing this date will fail
Try the below given expression,
DateTime.ParseExact(yourdatevariable.toString(),“ddd MMM dd hh:mm:ssyyyy”,Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy hh:mm:ss”)
Hello,
Please check using this expression
DateTime.ParseExact(“Thu Jan 20 00:00:00 2022”,“ddd MMM dd hh:mm:ss yyyy”,system.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)
Note: Please verify the week day first On Jan 20 2022 there is thursday. and try
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.