Question
Matjaz Murko · Feb 3, 2021

Date/Time add hours

Hi.

How can I add/substract hours from $Horolog in ObjectScript and the date part of $H is also affected?

Regards,

Matjaž

Product version: IRIS 2020.1
0
0 631
Discussion (5)2
Log in or sign up to continue

set diff=3600   ; time in sec
set new=$zdth($zdt($h,-2)-diff,-2) ; new $h - 1 hour

One thing to keep in mind with mode -2 is that the range of valid dates varies by platform. I think Windows is the most limited right now, throwing an ILLEGAL VALUE error for dates prior to 1970.

Hi.

Tnx for your answer. I was looking for intrinsic function...

Regards,

Matjaž

You should be able to use the $SYSTEM.SQL.DATEADD("hh",1,$H)

It returns a timestamp you'd need to convert back to $H format if that's what you need.

It's true, prior 1970 $ZDateTime with -2 format throws error. But that's no problem, because I'm using current date/time only. So the Robert's solution is fine for me.

Tnx!