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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
denwo2010
Creator
Creator

Add hour on to a Date?

Hi,


What is the best way to add 1 hour to a date, both by script and formula ?

i.e.

Current Date

12/10/2010 11:57:31

New Date

12/10/2010 12:57:31

Thanks

1 Solution

Accepted Solutions
hector
Specialist
Specialist

Hi, and something like this??

timestamp(yourfield - maketime(1))

rgds

View solution in original post

7 Replies
john_duffy
Partner - Creator III
Partner - Creator III

Hello.

You can create a variable representing 1 hour (ie. 1/24): set v1hour = .04167. This variable can then be used in the load script or as a formula.

For example, to create a field in the load script representing the current timestamp plus one hour:

timestamp(now() + $(v1hour)) as Curr_TS_Plus_1hour

John.

denwo2010
Creator
Creator
Author

Sorry I mean to say minus an hour,

Current Date

12/10/2010 11:57:31

New Date

12/10/2010 10:57:31

I tried what you said timestamp(now() - $(v1hour)) as Curr_TS_Plus_1hour but was not working.

john_duffy
Partner - Creator III
Partner - Creator III

Hello.

It should work. See the attached application. For greater precision I set v1hour to .04166667.

ivandrago
Creator II
Creator II

Hi John,

I have added your script but for me I have a date of 04/10/2010 11:41:00 but it is returning as 04/10/2010 10:10:00 where it should be 04/10/2010 10:41:00

Is there anyway you can hardcode the above date (04/10/2010 11:41:00) and see what results you are getting now?

Thanks

hector
Specialist
Specialist

Hi, and something like this??

timestamp(yourfield - maketime(1))

rgds

john_duffy
Partner - Creator III
Partner - Creator III

Hi Ivan.

Can you please attach a sample application demonstrating the issue. Thanks.

denwo2010
Creator
Creator
Author

This now works Hector! Thanks