If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

how can I subtract a number from datetime

Started by donlkj, 15 Feb 2013 07:57:22 AM

Previous topic - Next topic

donlkj

I have got two columns in DB2:

name:time_st   type: timestamp
name:duration   type: integer (means secundum)

example:
time_st: 2013-02-15 18:10:00 0000
duration: 300

task:
time_st-duration:
2013-02-15 18:10:00  - 300 sec, expected result: 2013-02-15 18:05:00


I tried but not working (in framework manager)
->   timestampadd(2, duration, time_st)
->   time_st - duration second (like currenttime - 3 second)

How can I solve it?

any idea?
donlkj

bi4u2

I am not sure what studio you are working in but there is an easy solution in Report Studio. Add a new data item to your query, go to the Functions tabs, then the Constants folder and grab an item called 'interval minute'. It inserts a '0 minute' but you can change this and the add or subtract this item to your timestamp item. I am attaching my results. I changed the interval to say '5 minute'.

donlkj

OK, but I would like to use 2 columns.( instead of constant.)
I have got a timestamp column, and from this timestamp column I would like to subtract an other column (which is integer).

And if it possible in the model.

blom0344

You could write an SQL query subject using DB2 syntax that allows using the seconds,microseconds etc definitions:

Select sometable.sometimestamp-(othertable.value)/1000 microseconds from ......................