Date Formatting

I have input date format is 3/12/1990 and i want this format in word document after replacing 12-March-1990.

Example
Input-3/12/1990
Output-12-March-1990

Hi @Himanshu_Pratap_Rana

How about this expression

DateTime.ParseExact("3/12/1990","M/dd/yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMMM-yyyy")

Regards
Gokul

Output @Himanshu_Pratap_Rana

image

Alternative Solution @Himanshu_Pratap_Rana

You can also try with Cdate

CDate("3/12/1990").tostring("dd-MMMM-yyyy")

image

1 Like

Input-Mon Mar 12 1990 05:30:00 GMT+0530 (India Standard Time)
Output-12-March-1990

Only want 12-Mar-1990 not 12-March-1990

Hi @Himanshu_Pratap_Rana

CDate("3/12/1990").tostring("dd-MMM-yyyy")

image

For this input You can try with Regex @Himanshu_Pratap_Rana

DateTime.ParseExact(System.Text.RegularExpressions.Regex.Match("Mon Mar 12 1990 05:30:00 GMT+0530","\S.{3}\d.{2}\d{4}").ToString.Trim,"MMM dd yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MMMM-yyyy")

image

Regards
Gokul

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