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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
una_xikilla
Contributor
Contributor

How to convert String to Date "yyyy-MM-dd'T'HH:mm:ss'Z'"

Hello

I have a string date. Eg: "20170922111613516888" and i want to convert it to Date "yyyy-MM-dd'T'HH:mm:ss'Z'".

 

how?? 0683p000009MPcz.png

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

So you want to convert your String into another String formatted as you state? OK, All you need to do is take what I have given you already and wrap it in this code.....

 

routines.TalendDate.formatDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", routines.TalendDate.parseDate("yyyyMMddHHmmssS", "20170922111613516888"))

 

View solution in original post

6 Replies
Anonymous
Not applicable

It looks like you may have one too many digits (too many 8s at the end?) but you can do it like below....

 

routines.TalendDate.parseDate("yyyyMMddHHmmssS", "20170922111613516888")

You do not need to worry about formats when creating Dates by the way. A Date is a unit of time. As a Date it has no format.

una_xikilla
Contributor
Contributor
Author

But i need to convert to "yyyy-MM-dd'T'HH:mm:ss'Z'"... Eg: 2017-07-26T01:00:00Z

and my input is a String(20). Eg: 20170922111613516888

Anonymous
Not applicable

So you want to convert your String into another String formatted as you state? OK, All you need to do is take what I have given you already and wrap it in this code.....

 

routines.TalendDate.formatDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", routines.TalendDate.parseDate("yyyyMMddHHmmssS", "20170922111613516888"))

 

una_xikilla
Contributor
Contributor
Author

I've try to do like this but don't work...

[statistics] connecting to socket on port 3798
[statistics] connected

[statistics] disconnected

0683p000009LqqU.png

Anonymous
Not applicable

I think you have misunderstood what is happening there. You are converting a String to a Date and the String must be in the format that is specified by the format. Once a Date object is created, format is totally irrelevant. It is a bit like a number. A number is just a value irrespective of format you display it in. To use a Date in calculations or to put in a database, you do not need to worry about format. To display a Date, then you need to deal with the format.

 

Basically, change the date format in your tLogRow and you will see it in the format you want it. But first you need to identify the correct format of the String to convert it to a Date.

una_xikilla
Contributor
Contributor
Author

oh! you're right (sorry)

 

Now work my job! Thank you! 0683p000009MA9p.png