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

Author Topic: How to use _add_hours((current_time),-3) in detail filter?  (Read 3815 times)

Offline lrjurgen

  • Full Member
  • ***
  • Join Date: Apr 2022
  • Posts: 10
  • Forum Citizenship: +0/-0
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...

Offline dougp

  • Statesman
  • ******
  • Join Date: Jul 2014
  • Posts: 911
  • Forum Citizenship: +30/-2
Re: How to use _add_hours((current_time),-3) in detail filter?
« Reply #1 on: 11 Apr 2022 06:27:56 pm »
Is create_stamp a date or string data type?

Offline lrjurgen

  • Full Member
  • ***
  • Join Date: Apr 2022
  • Posts: 10
  • Forum Citizenship: +0/-0
Re: How to use _add_hours((current_time),-3) in detail filter?
« Reply #2 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).

Offline dougp

  • Statesman
  • ******
  • Join Date: Jul 2014
  • Posts: 911
  • Forum Citizenship: +30/-2
Re: How to use _add_hours((current_time),-3) in detail filter?
« Reply #3 on: 12 Apr 2022 12:19:10 pm »
From what you have described

Code: [Select]
[wms].[it_f].[create_stamp] > _add_hours ( current_timestamp , -3)
will work.  Maybe there's a detail you didn't mention.