COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Legacy Components => Query Studio => Topic started by: lrjurgen on 11 Apr 2022 04:08:58 PM

Title: How to use _add_hours((current_time),-3) in detail filter?
Post by: lrjurgen on 11 Apr 2022 04:08:58 PM
Relative newbie/rookie to Cognos:
I am working in Cognos 11.1, trying to use _add_hours() comparing with a create_stamp in the data (SQL Server).

My create_stamp looks like this: 11 Apr, 22 3:30:51 PM

I am trying to pull back records where the create stamp is greater than current_time minus 3 hours.

I have tried the following and none are working:
[wms].[it_f].[create_stamp] > _add_hours ( current_date , -3)
[wms].[it_f].[create_stamp] > _add_hours ( current_time , -3)
[wms].[it_f].[create_stamp] > _add_hours ( current_timestamp , -3)

Tell me where I've gone off the rails here...
Title: Re: How to use _add_hours((current_time),-3) in detail filter?
Post by: dougp on 11 Apr 2022 06:27:56 PM
Is create_stamp a date or string data type?
Title: Re: How to use _add_hours((current_time),-3) in detail filter?
Post by: lrjurgen on 12 Apr 2022 08:22:48 AM
They call it a Timestamp data type in the screens I can see.
I'm assuming its a date/time data element. I don't have access to the DB directly (cloud system).
Title: Re: How to use _add_hours((current_time),-3) in detail filter?
Post by: dougp on 12 Apr 2022 12:19:10 PM
From what you have described

[wms].[it_f].[create_stamp] > _add_hours ( current_timestamp , -3)

will work.  Maybe there's a detail you didn't mention.