• 2 replies
  • Latest Post - ‏2013-07-25T13:53:11Z by Needaf1x
221 Posts

Pinned topic Adding 1 hour to system var &TOD

‏2013-07-03T23:12:41Z |


We use the system variable &TOD to output the report creation time in the footings of all our reports, eg:

"Report prepared &DATE at &TOD for user <D_USER"

However we are changing the time zone our system is running on by -1 hour, but want to keep the reports outputting their current time zone.  Is there a function for adding 1 hour to &TOD?



  • GeneCobb
    371 Posts

    Re: Adding 1 hour to system var &TOD


    Mark - I wish it was a bit easier, but this is the best I could come up with. It involves creating multiple Define fields. First you retrieve the current time, then add 1 hour, extract each time component (hour, minute, second), and finally piece those components back together. The final Define field (CurTim1) is what you would add to your report.

    CurDatTim/HYYMDS=HGETC(10, 'HYYMDS');
    CurDatTim1/HYYMDS=HADD(CurDatTim, 'HOUR', 1, 8, 'HYYMDS');
    CurHour1/I2L=HPART(CurDatTim1, 'HOUR', 'I2');
    CurMin1/I2L=HPART(CurDatTim1, 'MINUTE', 'I2');
    CurSec1/I2L=HPART(CurDatTim1, 'SECOND', 'I2');
    CurTim1/A8=EDIT(CurHour1) | ':' | EDIT(CurMin1) | ':' | EDIT(CurSec1) ;

  • Needaf1x
    221 Posts

    Re: Adding 1 hour to system var &TOD


    Hi Gene,

    Sorry for the late reply and thank you for your response and efforts.  However in the end we decided to keep the code simple and instead modified the footer  stating the time zone we are running in!

    "Report prepared &DATE at &TOD (GMT) for user <D_USER"

    Thanks again though!