i want to convert the string to date and time format in flow designer transform functions

rajamusani
Tera Contributor

For the date alone i had used custom type with this value: yyyyMMdd it worked fine.

Please suggest if any body worked on date and time from the string field

 

2025-07-22 08:45:00

4 REPLIES 4

Hemanth M1
Giga Sage
Giga Sage

Hi @rajamusani ,

 

Why don't to just use GlideDateTime() api as below.

var dateString = "2024-07-22 08:30:00";  //sample string
var gdt = new GlideDateTime(dateString); 
gs.info(gdt.getDisplayValue()); //date time type output

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

HI @rajamusani ,

 

Hope, above solution met your requirement if so,

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Pranesh072
Mega Sage
Mega Sage

You can use the custom format : yyyy-MM-dd '00:00:00'

 

Pranesh072_2-1753281196279.png

 

 

or ServiceNow Date/time 

Pranesh072_1-1753281070302.png

 

 

Hi Team,

Now i had changed to to the custom format yyyyMMddHHmmss, I will let you know after some testing results in my sub flow.

Thank you,

Rajasekhar