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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
lmit
Creator II
Creator II

[resolved] Adding 2 Dates

Hi,
                I want to add 2 dates which are coming in my input along with time.
My Input is
2015-02-26 08:00:00   1900-01-01 09:00:00

My Output should be
2015-02-26 17:00:00
In my output my date should be same which is coming from first column.
Thanks In advance
Lmit 
Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi Lmit,
Try the following approach:
1. Separate the 2 dates to be added; the 1st one would be of the format "yyyy-MM-dd HH:mm:ss" & the 2nd one of "HH:mm:ss"
2. Now extract the Hour, Minute & Seconds part from the 2nd date, & convert it to Integer format.
3. Then use something like this:
TalendDate.addDate(TalendDate.addDate((TalendDate.addDate(Var.base_time,"yyyy-MM-dd HH:mm:ss",Var.tobeadded_time_hh,"HH")),"yyyy-MM-dd HH:mm:ss",Var.tobeadded_time_mm,"mm"),"yyyy-MM-dd HH:mm:ss",Var.tobeadded_time_ss,"ss")  

This would add Hours, as well as Minutes, as well as Seconds.
Hope this should work for you. 0683p000009MACn.png
MathurM

View solution in original post

4 Replies
Anonymous
Not applicable

Get respectively the hours, minutes and seconds of the second date, for example,
tFileInputDelimited--main--tJavaRow--main--tMap....
on tJavaRow
context.hours=row1.secondColumnName.getHours();
context.minutes....

Then, add hours, minutes and seconds to the first date using built-in function on tMap, for example:
TalendDate.addDate(row1.firstColumnName,context.hours,"HH")

Best regards
Shong
lmit
Creator II
Creator II
Author

Thanks for your reply Shong...I need to consider Minutes and Seconds also.how can i get it?
My Input
2015-02-26 08:20:00 1900-01-01 09:40:00
Output 
2015-02-26 17:60:00.
Minutes and seconds also need to get added
Thanks In Advance
Lmit
Anonymous
Not applicable

Hi Lmit,
Try the following approach:
1. Separate the 2 dates to be added; the 1st one would be of the format "yyyy-MM-dd HH:mm:ss" & the 2nd one of "HH:mm:ss"
2. Now extract the Hour, Minute & Seconds part from the 2nd date, & convert it to Integer format.
3. Then use something like this:
TalendDate.addDate(TalendDate.addDate((TalendDate.addDate(Var.base_time,"yyyy-MM-dd HH:mm:ss",Var.tobeadded_time_hh,"HH")),"yyyy-MM-dd HH:mm:ss",Var.tobeadded_time_mm,"mm"),"yyyy-MM-dd HH:mm:ss",Var.tobeadded_time_ss,"ss")  

This would add Hours, as well as Minutes, as well as Seconds.
Hope this should work for you. 0683p000009MACn.png
MathurM
Anonymous
Not applicable

I performed the whole operation in a tMap (you can work with any other component of your choice)
The following is the output
0683p000009MC1m.png