Datetime type conversion issue

I have a variable of type DateTime assigned with value – abc = System.DateTime.Now.

I need an output with date format as - dd-MMM-yy hh:mm:ss.

Kindly help!

Hi
Yah like this
str_datevalue = DateTime.Now.ToString(“dd-MMM-yy hh:mm:ss”)

Where str_datevalue is a variable of type string

Cheers @Mahalakshmi

Thanks for the revert!

You have mentioned DateTime.Now. What if I need to use an old date? and I have that old date in another variable

Fine
May I know that date format
So that we can come with a expression to parse to your required output format

Cheers @Mahalakshmi

Input - 01/15/2020 11:55:54

My required output - 15-JAN-20 11:55:54

1 Like

Awesome
If the input is stored in a variable named strinput then use this expression
str_output = DateTime.ParseExact(strinput.ToString,”MM/dd/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd-MMM-yy hh:mm:ss”)

Cheers @Mahalakshmi

1 Like

Thanks!

Worked ! :slight_smile:

1 Like

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