Written by

Question Lionel Woods · Nov 2, 2021

Capturing Date/Time in call

I am using the following code to capture the current Date/Time and Date/Time from the previous 15 minutes 

set now=$horolog
$$$TRACE("now:"_now)set time15min = $piece(now,",",*) - (15 * 60)
$$$TRACE("time15min"_time15min)set after = $piece(now,",",1)_","_time15min
$$$TRACE("after"_after)set datetime15=$zdatetime(after, 3)
$$$TRACE("datetime15"_datetime15)set datetimenow=$zdatetime(now, 3)
$$$TRACE("datetimenow"_datetimenow)set datetime15=$replace(datetime15," ","T")
$$$TRACE("datetime15"_datetime15)set datetimenow=$replace(datetimenow," ","T")
$$$TRACE("datetimenow"_datetimenow)

The issue I am having is that it errors at midnight as it cannot account for the previous day and the previous 15 mins (Time being 23:45)

Is there an "If" statement I can write to resolve this or something else?

Thank you in advance 

Product version: HealthShare 2017.2

Comments

Matjaz Murko · Nov 2, 2021

Hi.
Have you tried:

Set time15min=$SYSTEM.SQL.Functions.DATEADD("mi",-15,$ZDateTime(now,3))

Regards,
Matjaž

0