COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Laynlowz on 12 Jun 2024 03:03:46 PM

Title: Subtract minutes from Date/time field
Post by: Laynlowz on 12 Jun 2024 03:03:46 PM
How can I subtract minutes from a date/time field?


example is
Jun 4, 2024 12:20:45 AM

I want to subtract 12 hours from this to read
Jun 3, 2024 12:20:45 AM

there is a number of records with different date/times in the database so it would be any date/time record needs to have 12 hours subtracted.

I have tried _add_hours([Performance and Throughput].[Event Summary Header].[Facility - Event Start Date Time] , -12)  but the query just fails after running with no clear indicator of why it fails.
Title: Re: Subtract minutes from Date/time field
Post by: bus_pass_man on 12 Jun 2024 04:04:57 PM
Really?  Nothing in the logs?

It works for me.  What's the data type of the column you are using?  Is it possible that there are other variables in play which you have not mentioned?

add_negative_hours works for me.png

Quotethere is a number of records with different date/times in the database so it would be any date/time record needs to have 12 hours subtracted.
Are.  Not quite sure what you mean.  Also, I'm not sure if what you mean by record is what is commonly understood to be record.

Also the time stamp data type and the 12 hours business makes me think this is related to https://www.cognoise.com/index.php/topic,38131.0.html
Title: Re: Subtract minutes from Date/time field
Post by: Laynlowz on 13 Jun 2024 09:52:53 AM
this is the error i receive

XQE-GEN-0018 Query Service internal error has occurred, please see the log for details.
CAF-WRN-2082 An error has occurred. Please contact your administrator. The complete error has been logged by CAF with SecureErrorID:2024-06-13-14:31:03.549-#1544
Title: Re: Subtract minutes from Date/time field
Post by: Laynlowz on 13 Jun 2024 10:37:30 AM
Nevermind that formula works there was a weird data item that was left in the query that caused this.

Thanks!