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

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

DateAdd function

Hi,

I have a function that I’m using in another application that I need to replicate in Qlikview.  The function is

DateAdd ("s",{metric_date_store.numeric_qty},{metric_date_store.datetime_dttm} )

It’s adding the value of metric_date_store.numeric_qty to metric_date_store.datetime_dttm.  Metric_date_store.numeric_qty is a duration of time stored in seconds.

Is there an equivalent function I can use when setting up my load script?  Any guidance would be greatly appreciated.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try: timestamp (datetime_dttm + interval#(numeric_qty,'s')) as End_Time

Or datetime_dttm + numeric_qty/86400


talk is cheap, supply exceeds demand

View solution in original post

7 Replies
luciancotea
Specialist
Specialist

You can define your function as a VBA macro and call it from load script: http://luciancotea.wordpress.com/2013/07/04/call-vba-macro-function-from-the-load-script/

Not applicable
Author

Thanks - I was hoping that QlikView had a function that could add time to an existing date field.  I'd prefer that approach versus referencing an external macro.  I'll take a look - thanks again.

luciancotea
Specialist
Specialist

To add time to a date is easy. Date is integer value representing how many days passed since 30/12/1899, time is fractional value representing how many miliseconds passed from midnight. Toghether they represent DateTime value.

So, 1 second = 1/24/60/60

       1 minute = 1/24/60

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Should be pretty simple.

timestamp( metric_date_store.datetime_dttm + interval(metric_date_store.numeric_qty,'s') )

-Rob

http://masterssummit.com

http://robwunderlich.com

Not applicable
Author

Hi - I thought this would work but when I add

 

timestamp (datetime_dttm + interval(numeric_qty,'s')) as End_Time

to my load script looks like its adding years, not seconds to the datetime_dttm field.

Here is an example:

Description   Start_Time   Duration_In_Minutes   numeric_qty   End_Time  
BUWY-DEV6/22/2013 4:55:12 AM24214548.000004/21/2053 4:55:12 AM
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try: timestamp (datetime_dttm + interval#(numeric_qty,'s')) as End_Time

Or datetime_dttm + numeric_qty/86400


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks!  This worked.