Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
P_Kale
Creator II
Creator II

How to covert date which is in YYYY-MM-DD 00:00:00:000 to DD/MM/YYYY

Hi,

How to convert date which is in YYYY-MM-DD 00:00:00:000 to DD/MM/YYYY. Expected out-put 27/12/2021

CHDRNUM NEW_RECPTDT
00000314 2021-12-27 00:00:00.000

 

Thanks in advance

@marcus_sommer 

Labels (1)
1 Solution

Accepted Solutions
P_Kale
Creator II
Creator II
Author

Hi @steeefan I have checked the actual value stored in the column and it is a number so i have used below function to get solution.

date(num#(NEW_RECPTDT),'DD/MM/YYYY') AS NEW_RECPTDT

Thanks

View solution in original post

7 Replies
steeefan
Luminary
Luminary

One possibility:

 

Date(Date#(NEW_RECPTDT, 'YYYY-MM-DD hh:mm:ss.fff'), 'DD/MM/YYYY') AS NEW_RECPTDT_DT

 

 

steeefan_0-1707382840222.png

Akash_Pohare
Contributor III
Contributor III

You can set the global variable to -  SET DateFormat='DD/MM/YYYY';

and then use Date(Floor(NEW_RECPTDT)) AS NEW_RECPTDT_Updated in the script.

P_Kale
Creator II
Creator II
Author

Thanks @steeefan 

When i am trying at my end the column is become blank.

qv_testing
Specialist II
Specialist II

May be this...

LOAD *, Date(Date#(SUBFIELD(NEW_RECPTDT,'.',1),'YYYY-MM-DD h:mm:ss'),'DD/MM/YYYY') as NewField;

 

steeefan
Luminary
Luminary

Are you sure your timestamp is exactly formatted as 2021-12-27 00:00:00.000? This code works for me on the format and data you specified. I also added a second option:

 

LOAD
  CHDRNUM,
  NEW_RECPTDT,
  Date(Date#(NEW_RECPTDT, 'YYYY-MM-DD hh:mm:ss.fff'), 'DD/MM/YYYY') AS NEW_RECPTDT_DT1,
  Date(Date#(Left(NEW_RECPTDT, 10), 'YYYY-MM-DD'), 'DD/MM/YYYY') AS NEW_RECPTDT_DT2;
LOAD * INLINE [
  CHDRNUM, NEW_RECPTDT
  00000314, 2021-12-27 00:00:00.000
];

 

 

steeefan_0-1707386045893.png

Pablo007
Creator
Creator

Dear @P_Kale,

 

You can try:

 

Alt(Date#(NEW_RECPTDT,'YYYY/MM/DD'),Date#(NEW_RECPTDT,'DD/MM/YYYY')) as NEW_RECPTDT2,

P_Kale
Creator II
Creator II
Author

Hi @steeefan I have checked the actual value stored in the column and it is a number so i have used below function to get solution.

date(num#(NEW_RECPTDT),'DD/MM/YYYY') AS NEW_RECPTDT

Thanks