17
Views
3
Comments
Solved
Date Format
Question
Application Type
Reactive

How can i convert date format yyyyMMdd to yyyy-MM-dd ?


Example : 

20200129 need to change 2020-01-29 in this format
Rank: #54
Solution

Hi Ranjeet,


Assuming your text is stored in a variable DateText, you can use the following (change DateText to the name of the variable you have the text):

FormatDateTime(NewDate(TextToInteger(Substr(DateText,0,4)), TextToInteger(Substr(DateText,4,2)), TextToInteger(Substr(DateText,6,2))), "yyyy-MM-dd")


Basically, it creates a new date using the first 4 digits for year, the next 2 for month and the last 2 for day, and uses the format function to format it into to the yyyy-MM-dd format you want.

Regards,
João

Hi Ranjeet,

Good day!

As far as I know, for that, you have to manually break the string to align with the expected date format conversion. But we can for other members to have their comments.

Thank you and kind regards,

Chris

Rank: #54
Solution

Hi Ranjeet,


Assuming your text is stored in a variable DateText, you can use the following (change DateText to the name of the variable you have the text):

FormatDateTime(NewDate(TextToInteger(Substr(DateText,0,4)), TextToInteger(Substr(DateText,4,2)), TextToInteger(Substr(DateText,6,2))), "yyyy-MM-dd")


Basically, it creates a new date using the first 4 digits for year, the next 2 for month and the last 2 for day, and uses the format function to format it into to the yyyy-MM-dd format you want.

Regards,
João

Rank: #287

Hi Ranjeet,

You can simply split the text and add  hyphens between them
Substr(DateText,0,4))+ "-" + Substr(DateText,4,2) + "-" + Substr(DateText,6,2

Regards,