Date time formate

I am taking user input of date format as string dd/MM/yyyy and user can enter as 12/May/2020 i am using i want to convert it to datetime variable and then wants to convert month to number like MAY to 5 .

Hi,

We can convert both style string to DateTime type as the following.

d = DateTime.ParseExact(text,{"dd/M/yyyy","dd/MMM/yyyy"},nothing,nothing)

then, we can easily get the string as follows:

d.ToString("dd/M/yyyy")

Regards,

1 Like

Can u send a screenshot of the line unable to do it

Hi,

Hope the following helps you.

img20201217-1

The following might be better if there is 04, 4 , Apr or April as April.

d = DateTime.ParseExact(text,{"dd/M/yyyy","dd/MM/yyyy","dd/MMM/yyyy","dd/MMMM/yyyy"},nothing,nothing)

Regards,

I have a workflow in which i am entering date and month in a flight booking website in that I am asking user the date as dd/MM/yyyy and according to month i have put condition inside while loop but if user enters month in text as MAY the line is not able to convert it to to date time
Main-1.xaml (18.5 KB)

Hi,

In this case, the following might be better.

d = DateTime.ParseExact(text,{"d/M/yyyy","d/MMM/yyyy","d/MMMM/yyyy"},nothing,nothing)

Can you share some examples of user input string?

Regards,

Hi,

2/MAY/2020

The following will work. Can you try this?

d = DateTime.ParseExact(text,{"d/M/yyyy","d/MMM/yyyy","d/MMMM/yyyy"},nothing,nothing)

Regards,

Its working thanks

1 Like