3393
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
2018-10-29 08-31-03
João Marques
 
MVP
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

2024-10-25 09-14-42
Christopher Bautista

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

2018-10-29 08-31-03
João Marques
 
MVP
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

2021-01-19 14-07-32
Tom Zhao

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,

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.