Unable to convert date format to DD-MM-YYYY

sainath3
Giga Guru

Hi All,

 

In my User profile changed the date format to dd-MM-yyyy.

 

am loading the data thr transform, in source table for the start date field  i have taken as string.

in Source table date is 19-03-2025.

Am just mapping to the target field, but in target field it showing as "14-09-0024".

If I try with new GlideDateTime() it is returning as "2025-03-19"

Don't know how it has changed.

 

but I want date should be same as Source table date "19-03-2025"

Can you please help me.

2 ACCEPTED SOLUTIONS

Shree_G
Mega Sage

Hello @sainath3 ,

 

You can use below code to ensure the format.

var new gdt = new GlideDate();

gdt.getByFormat("dd-MM-yyyy");

 

View solution in original post

@sainath3 

see the date will be set properly in target field

But the date it will display is based on your date format in sys_user or in preferences

If my response helped please mark it correct and close the thread so that it benefits future readers.

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron

@sainath3 

it's nothing to do with your user profile date format

the field map for that date, you can the date format there and the date format should be dd-MM-yyyy as the date will come in that format in source table

Click on that suggestion icon and select the date format

AnkurBawiskar_0-1744695624539.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Hi Ankur,

I have tried to change the date fromat in field script to dd-MM-yyyy.

Still showing wrong format

@sainath3 

see the date will be set properly in target field

But the date it will display is based on your date format in sys_user or in preferences

If my response helped please mark it correct and close the thread so that it benefits future readers.

Shree_G
Mega Sage

Hello @sainath3 ,

 

You can use below code to ensure the format.

var new gdt = new GlideDate();

gdt.getByFormat("dd-MM-yyyy");