Written by

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

Comments

Robert Cemper · Feb 3, 2021

set diff=3600   ; time in sec
set new=$zdth($zdt($h,-2)-diff,-2) ; new $h - 1 hour
0
Jon Willeke  Feb 3, 2021 to Robert Cemper

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.

0
Matjaz Murko · Feb 3, 2021

Hi.

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

Regards,

Matjaž

0
Warlin Garcia · Feb 3, 2021

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.

0
Matjaz Murko · Feb 3, 2021

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!

0