Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
eyadelnagdy
Contributor II
Contributor II

converting data type from string to data and time

Hello everyone,

in qlik sense

I have a timestamp in a string format and I need to convert it into a date and time with e specific format.

the idea is to be able to create a calendar or extracts month.week...etc from that field, which is not possible when it's a string

 

5 Replies
henrikalmen
Specialist II
Specialist II

Use the date#() function.

eyadelnagdy
Contributor II
Contributor II
Author

when I use date#(fieldname) it generated another column which is actually the same

if I try to do Month(date#(filename)) it doesn't extract the month which means it doesn't understand it as a date

henrikalmen
Specialist II
Specialist II

No, you need to specify the format. If your date in a field MyDateField
is a text value like '09/12/24 13:00' then you do date#(MyDateField,
'DD/MM/YY hh:mm').

Please read the manual for the date#() function that I linked to.
BrunPierre
Partner - Master II
Partner - Master II

Date(Floor(Date#(Field,'YYYY-MM-DD hh:mm:ss.fffffff +ff:ff')),'DateFormat')

eyadelnagdy
Contributor II
Contributor II
Author

I found an easier solution. I used left(fieldname, 19) to extract the first 19 characters which includes the seconds and qlik recognised automatically the date and time