Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Convert dates from yyyy-mm-dd and yyyymmdd to mm-dd-yyy

Hi,

I have a date field , and the dates are displayed in the yyyy-mm-dd and yyyymmdd format I need to convert it into one format ie mm-dd-yyy in the script editor

Thx

B

1 Solution

Accepted Solutions
swarup_malli
Specialist
Specialist

try this

 

alt(date#(MyDateField, 'YYYY-MM-DD'), date#(MyDateField, 'DD-MM-YYYY'), date#(MyDateField, 'DD/MM/YYYY'), 'No Date Found') AS

MyDateField

Thx

MS

View solution in original post

5 Replies
Not applicable
Author

Did you try > date(datefield, 'MM-DD-YYYY')

Anonymous
Not applicable
Author

Thanks nick for the reply

I know the following can be used

date(date#(MyDateField,'yyyymmdd'),'yyyy-mm-dd')

My questions is  there a better way to do this when the filed contains dates in different formats

swarup_malli
Specialist
Specialist

try this

 

alt(date#(MyDateField, 'YYYY-MM-DD'), date#(MyDateField, 'DD-MM-YYYY'), date#(MyDateField, 'DD/MM/YYYY'), 'No Date Found') AS

MyDateField

Thx

MS

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try with Alt() and Date#()

Date(Alt(Date#(DateFieldName, 'yyyy-mm-dd'), Date#(DateFieldName, 'yyyymmdd')), 'mm-dd-yyy')

Regards,

Jagan.

anandathome
Creator
Creator

Hi Balraj,

      If you are very sure that there are two types of dates in your data and they are in the format you mentioned, then this solution will work for you.

Let us know if this helps you