416
Views
7
Comments
Solved
Change to text date to date format
Question

Hi,

Can someone know how could I convert this text Apr 5, 2023, 9:28 AM into YYYY-mm-dd hh:mm:ss?

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

Hi Ruzzel,

Assuming the date/time formats are somewhat common, and you only need them client-side, JavaScript can easily convert it for you. To do so, create a Client Function, e.g. MyTextToDateTime, with a Text as input, and a Date Time as output. Inside the Function, add a JavaScript node, with an Input Parameter of type Text, and an output of Date Time, like this:

Then assign the output of the JavaScript node to the output parameter of the Function.

However, note that if you need the conversion server side, the above obviously doesn't work. In that case, you'll have to manually parse it. There may be some Forge assets to help you with it, but I didn't search.

UserImage.jpg
Ruzzel John Bisnar

Hi Killian,


Thank you I already solve it using also this solution.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Ruzzel,

Great it worked for you. Happy coding!

2024-10-07 06-43-19
Aanchal Sharma
Solution

hi @Ruzzel John Bisnar 

there are not any particular function which support such format we have to use multiple functions to achieve it..

please follow such step

 Steps: 

Using substr() in-built function, extract the date value

Split the Date text value with / as delimiter, using the String_Split function referenced from Text Extension

Mend the Date text value, from the split function return value in a default date format yyyy-mm-dd

Using the TextToDate() conversion function, convert the text Date value to Date data type value


and you can achieve it by JavaScript too as  Kilian Hekhuis answered.

UserImage.jpg
Ruzzel John Bisnar

I did the way of Kilian very straight forward.


Thank you

2023-01-26 16-03-24
Ana Agostinho

Hello Ruzzel John Bisnar, 

I believe there isn't a straight forward way of doing that. Basically, my strategy would be: 

  1. Make the "Apr 5, 2023, 9:28 AM " readable by the TextToDateTime function, meaning, making it appear like one of the following formats (yyyy-mm-dd hh:mm:ss, yyyy/mm/dd hh:mm:ss, and yyyy.mm.dd hh:mm:ss) using Text functions.

 

        2. After that, you can use the FormatDateTime() function and change the date format of the date. 


Here are some forum posts with more or less the same issue you are facing in functions/format. 

Best regards, 

Ana

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

Hi Ruzzel,

Assuming the date/time formats are somewhat common, and you only need them client-side, JavaScript can easily convert it for you. To do so, create a Client Function, e.g. MyTextToDateTime, with a Text as input, and a Date Time as output. Inside the Function, add a JavaScript node, with an Input Parameter of type Text, and an output of Date Time, like this:

Then assign the output of the JavaScript node to the output parameter of the Function.

However, note that if you need the conversion server side, the above obviously doesn't work. In that case, you'll have to manually parse it. There may be some Forge assets to help you with it, but I didn't search.

UserImage.jpg
Ruzzel John Bisnar

Hi Killian,


Thank you I already solve it using also this solution.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Ruzzel,

Great it worked for you. Happy coding!

2021-12-22 12-25-29
Vaishnavi Bokade

Hello @Ruzzel John Bisnar ,

you can take a look at this post Link : https://www.outsystems.com/forums/discussion/16546/text-to-date-conversion/

I hope it will help you.



Thanks

Vaishnavi Bokade

2024-10-07 06-43-19
Aanchal Sharma
Solution

hi @Ruzzel John Bisnar 

there are not any particular function which support such format we have to use multiple functions to achieve it..

please follow such step

 Steps: 

Using substr() in-built function, extract the date value

Split the Date text value with / as delimiter, using the String_Split function referenced from Text Extension

Mend the Date text value, from the split function return value in a default date format yyyy-mm-dd

Using the TextToDate() conversion function, convert the text Date value to Date data type value


and you can achieve it by JavaScript too as  Kilian Hekhuis answered.

UserImage.jpg
Ruzzel John Bisnar

I did the way of Kilian very straight forward.


Thank you

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