Focal Point
[SOLVED]Get 12 hours ago from current datetime

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/1847009186

April 19, 2016, 01:16 PM
cs_source
[SOLVED]Get 12 hours ago from current datetime
I need to get 12 hours ago from the current date time in date time format. After some searching i have the ability to get one day ago (below) however i would like to just specify 12 hours ago.

Example:
current datetime is 2016-04-19 21:00
then get variable for 2016-04-19 09:00

Example:
current datetime is 2016-04-19 10:00
then get variable for 2016-04-18 22:00

-*this is what i have for one day ago from current datetime, i'm not sure if i can build on it?
-SET &CURR_DT_RAW=HCNVRT(HGETC(20,'HYYMDS'),'(HYYMDS)',20,'A20');
-SET &CURR_DT=HCNVRT(HADD(HGETC(20,'HYYMDS'),'DAY',-1,8,'HYYMDS'),'(HYYMDS)',20,'A20');

This message has been edited. Last edited by: <Emily McAllister>,
April 19, 2016, 01:38 PM
Squatch
Try this:

-SET &ECHO=ALL;
-SET &CURR_DT_RAW=HADD(HGETC(20,'HYYMDS'),'HOUR',-12,20,'HYYMDS');
-SET &CURR_DT_ALPHA=HCNVRT(&CURR_DT_RAW,'(H14)',14,'A14');
-TYPE &CURR_DT_ALPHA



App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
April 19, 2016, 01:49 PM
cs_source
quote:
l

Thanks Squatch, this works:

-SET &CURR_DT=HCNVRT(HADD(HGETC(20,'HYYMDS'),'HOUR',-12,8,'HYYMDS'),'(HYYMDS)',20,'A20');


WebFocus 8.02, SQL Server 2008r2
April 19, 2016, 06:17 PM
Waz
Please add [SOLVED] or [CLOSED] to the title your first post in this thread.

This way we all know its been resolved.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!