Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Add Hours to Timestamp

Is there a simple way to add hours to a date. I am hoping that it is not a long converting & concatenating.

Thanks,

Dinesh.

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

If it's a field containing a numeric number of hours:

timestamp(MyDate + NumberOfHours/24)

Or if you're adding a specific number of hours:

timestamp(MyDate + 50/24)

View solution in original post

4 Replies
Miguel_Angel_Baeyens

Hello Dinesh,

Use the following example

=Date(Date('02/03/2010') + time('22:30', 'hh:mm'), 'DD/MM/YYYY hh:mm:ss')


Hope this helps

vgutkovsky
Master II
Master II

Dinesh,

Try this: timestamp(date#('01/01/2010','MM/DD/YYYY') + maketime(10))

where 01/01/2010 is your date and 10 is the # of hours you want to add. If you have a date field, it would look like this:

timestamp(mydatefield + maketime(10)) as newdatefield

Regards,

johnw
Champion III
Champion III

If it's a field containing a numeric number of hours:

timestamp(MyDate + NumberOfHours/24)

Or if you're adding a specific number of hours:

timestamp(MyDate + 50/24)

Anonymous
Not applicable
Author

Miguel,

My problem is the inverse. I need to know only hours to compare with a specific value.

I need to compare a DtField which has this format 'DD-MM-YYYY hh:mm:ss' with a value Date#('06:30','hh:mm').

If its bigger than 6:30, count a Quantity of another field.

But comparing isnt working. I need maybe to broke in a new field?

Thanks !