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

Announcements
Note: You may notice some temporary visual or styling issues in the Community. Our vendor is actively investigating.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

extracting date and time as separate columns from same column

Hi all,

 

I have a requirement to extract date and time as separate column from the same column.

my input column has data like "2018-09-27 18:48:24"

i want column1 to have data like "2018-09-27" and column2 to "18:48:24".

i tried TalendDate.formatDate("yyyy-MM-dd", input column name), but it didn't worked.

 

Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi @shong ,

 

I found that the source column had data only for HH:mm so i changed the from HH:mm:ss to HH:mm. it worked. 

View solution in original post

14 Replies
manodwhb
Champion II
Champion II

@keshav1991 , you need to convert date data type to sting and then split  based on space.

 

TalendDate.formatDate("yyyy-MM-dd hh:mm:ss", input column name)

 

 

Anonymous
Not applicable
Author

Hi @manodwhb ,

i need to convert from the input column right?

Regards,

Keshav

manodwhb
Champion II
Champion II

@keshav1991 , yes

Anonymous
Not applicable
Author

I Have changed the input column to string and i used the "formatDate" function, but no luck.

 


screenshot_4.jpg
Anonymous
Not applicable
Author

attaching screenshot from tmap


screenshot_5.jpg
manodwhb
Champion II
Champion II

@keshav1991 , what is the source data type for relationship_created_on ,if it is string, then you can split based on space.

knknaveen
Contributor II
Contributor II

Hi Keshav,

 

formatDate output will be of string type. So, you need to parse it to date type before loading it into a date column.

 

Below script will help you split date & Time stamp separately.

 

TalendDate.parseDate("yyyy-MM-dd",TalendDate.formatDate("yyyy-MM-dd",row2.HIRE_DATE_TIMESTAMP ))

 

TalendDate.parseDate("HH:mm:ss",TalendDate.formatDate("HH:mm:ss", row2.HIRE_DATE_TIMESTAMP))

 

PFB TMap configuration for reference.

 

0683p000009M8O3.png

 

 

Anonymous
Not applicable
Author

Relationship_created_on column is of datetime datatype, and when i test it from tmap console i am getting below error.

 


screenshot_6.JPG
Anonymous
Not applicable
Author

attaching the error screenshot.

do i need worry about it or simply i can ignore and move forward


screenshot_7.JPG