String to Date Conversion

Hi Team,

In my project I have list of dates in the string variables. I want to convert these strings into date format and then change the date format into another format.

To be clear, what I want is:-

“dd/mm/yyyy” string I need to convert to “dd-MMM-yyyy” date format

For example:-

18/12/2019 to 18-Dec-2019

Kindly help.

Thanks and Regards,
@hacky

@hacky,

try like the following,

String requiredDate = DateTime.ParseExact(yourDate, "dd//MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).Tostring("dd-MMM-yyyy")
1 Like

Let say you have your date into a String called myDate.

You can make an assign activity where myDate will take this value:

myDate = DateTime.ParseExact(myDate,"dd/MM/yyyy",Nothing).ToString("dd-MMM-yyyy")

@smiui

When I save the RHS of the “=” into some variable (let’s say myDate), as I checked, it shows the variable type to be Generic Value.

How do I consider my variable (myDate) to be a DateType and into the given format
?

@sarathi125

My expectation is that input is STRING but the output is DATE TYPE.

How do I do this?

You said that you have some date into a String variable. There is no need to save it as DateTime, because you can convert to another format in same variable.
myDate is a String variable.

In case you need the date as DateTime variable, you can declare a new variable as System.DateTime and it will take the value: DateTime.ParseExact(myDate,"dd/MM/yyyy",Nothing)Main.xaml (8.8 KB)