Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] How to add one hour from the date/timestamp

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] How to add one hour from the date/timestamp
 Login/Join
 
Member
posted
I am searching for a way to add one hour from the date/time stamp to generate my output for a different timezone. Is there a way to do it with the date/time stamp or will I need to separate them?

This message has been edited. Last edited by: Tamra,


Into the Memory Hole!
 
Posts: 9 | Registered: March 16, 2007Report This Post
Expert
posted Hide Post
Have you looked into the HADD function?

"The HADD function increments a date-time value by a given number of units", including "year, quarter, month, day-of-year, day or day-of-month, week, weekday, hour, minute, second, millisecond, microsecond".

Syntax: HADD(value, 'component', increment, length, outfield)


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Gold member
posted Hide Post
Try using the HSETPT function. Example: DPR01/HYYMDS = HSETPT(DPR00,'HOUR',01,8,'HYYMDS');


WF 766
Win2K
 
Posts: 50 | Location: North Carolina | Registered: May 16, 2006Report This Post
Virtuoso
posted Hide Post
Winston

I did a search on focalpoint and found this

https://forums.informationbuilders.com/eve/forums/a/tpc/...071081491#9071081491

This might be helpful.

There is also an item on Reportcaster and a techdoc on the Webfocus site.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Member
posted Hide Post
My Final Answer:

DT2/HYYMDS=HGETC(10, 'HYYMDS'); Get current date and time
DT3/HYYMDS=HADD(DT2, 'HOUR', 1, 8, 'HYYMDS'); add one hour for Central Time
DT4/MDYY=HDATE(DT3,'MDYY'); Extract date
TMHR1/I2L=HPART(DT3, 'HOUR', 'I2'); Extract hour
TMMIN1/I2L=HPART(DT3, 'MINUTE', 'I2'); extract minute
TMSEC1/I2L=HPART(DT3, 'SECOND', 'I2'); extract seconds
TMTIME/A8=EDIT(TMHR1) | ':' | EDIT(TMMIN1) | ':' | EDIT(TMSEC1) ; concatenate time

I pulled current date/time first then extracted components so that the date would be correct between 12:00 pm and 1:00 am.


Into the Memory Hole!
 
Posts: 9 | Registered: March 16, 2007Report This Post
Silver Member
posted Hide Post
quote:
Originally posted by Francis Mariani:
Have you looked into the HADD function?

"The HADD function increments a date-time value by a given number of units", including "year, quarter, month, day-of-year, day or day-of-month, week, weekday, hour, minute, second, millisecond, microsecond".

Syntax: HADD(value, 'component', increment, length, outfield)


Hi Francis,

Can this be used with Dialoge Manager too? I'm trying to subtract 24 hours from the current system date/time and not having much luck. Any ideas?
Carol


------------------------------------------
last version used: v7.1; truly miss the wonderful things I did with WebFOCUS, HTML, & JavaScript.
 
Posts: 36 | Location: Rolling Meadows, IL | Registered: September 05, 2007Report This Post
Expert
posted Hide Post
I haven't used it directly with Dialogue Manager so I can't answer that, but, sometimes, when you can't do something with Dialogue Manager, you do it with TABLE.

Here's an example where I add five minutes to a DM variable that contains the current Date/Time:

-SET &ECHO=ALL;

SET HOLDLIST   = PRINTONLY
SET HOLDFORMAT = ALPHA
-RUN

-SET &CURR_DATE = &YYMD;
-SET &CURR_TIME = EDIT(HHMMSS('A8'),'99$99$99');

-SET &CURR_DTTM = &CURR_DATE | &CURR_TIME;

TABLE FILE CAR
PRINT CAR NOPRINT
COMPUTE CURR_DATE/HYYMDS = HINPUT(14, '&CURR_DTTM', 8, 'HYYMDS'); NOPRINT
COMPUTE NEW_DATE/HYYMDS  = HADD(CURR_DATE, 'MINUTE', 5, 8, 'HYYMDS'); 
WHERE RECORDLIMIT EQ 1
ON TABLE HOLD
END
-RUN

-READ HOLD &NEW_DATE.A8. &NEW_TIME.A6.

-TYPE &NEW_DATE - &NEW_TIME


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
I had some "date/time" on my hands, so here is how to do it in Dialogue Manager, using nested date/time functions.

-SET &ECHO=ALL;

SET HOLDLIST   = PRINTONLY
SET HOLDFORMAT = ALPHA
-RUN

-SET &CUR_DATE = &YYMD;
-SET &CUR_TIME = EDIT(HHMMSS('A8'),'99$99$99');

-SET &CUR_DTTM = &CUR_DATE | &CUR_TIME;

-*-- Syntax --------------------------------------------------
-*-- HINPUT(inputlength, 'inputstring', length, outfield)
-*-- HADD(value, 'component', increment, length, outfield)
-*-- HCNVRT(value, '(fmt)', length, outfield)

-SET &NEW_DTTM = HCNVRT(HADD(HINPUT(14, '&CUR_DTTM.EVAL' , 14, 'HYYMDS'), 'MINUTE', 5, 8, 'HYYMDS'), '(HYYMDS)', 20, 'A20');

-SET &NEW_DTTM1 = EDIT(&NEW_DTTM, '9999$99$99$99$99$99');

-TYPE Old: &CUR_DTTM / New: &NEW_DTTM or &NEW_DTTM1


HINPUT converts a alpha Dialogue Manager variable to a Date/Time value. HADD increments the Date/Time value by the specified component and amount. HCNVRT converts the incremented Date/Time value back to an alpha Dialogue Manager variable. One caveat: the value returned contains / and : separators which can easily be removed using EDIT. I could have nested the EDIT with the other functions, but that would have been overkill.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
For Cmallain's question: how about
-SET &YESTERDAY = AYMD( &YYMD , -1 , 'I8YYMD');




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Expert
posted Hide Post
Susannah, yup, AYMD would be the right function if she wanted to subtract a number of days.

Cheers.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
which she is... 24 hours, she says... thats 1 day... unless its billable time Smiler




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Silver Member
posted Hide Post
You both are awesome!!! Thanks so much!!! I'll give it a try. I do need to subtract hours though...it all depends but thanks for reminding me about AYMD too.


------------------------------------------
last version used: v7.1; truly miss the wonderful things I did with WebFOCUS, HTML, & JavaScript.
 
Posts: 36 | Location: Rolling Meadows, IL | Registered: September 05, 2007Report This Post
Silver Member
posted Hide Post
In case anyone needs it, here is Francis' wonderful code, but using the system time that contains milliseconds(HH:MM:SS:msmsms)

-*here are the individual steps needed to add 12hrs to the time and then present final with date:
-*1).get system time with milliseconds;
-*2).add 12 hours;
-*3).convert to look presentable in alpha;
-*get the time in HH:MM:SS:msmsms i.e. (&NOWDTTM = 2007/09/26 10:38:44.614797)
-SET &NOWTIME=HGETC(10,'HHISSM');
-*add 12hrs to time only
-SET &NOWTM12=HADD(&NOWTIME,'HOUR',12,10,'HHISsm');
-*convert so that it doesn't look like garbage
-SET &NOWTM=HCNVRT(&NOWTM12, '(HHISsm)', 15, A15);
-*here is one step to get it all done at once
-SET &NOWTIME=HCNVRT(HADD(HGETC(10,'HHISSM'),'HOUR',12,10,'HHISsm'),'(HHISsm)',15,A15);
-*then merge with date:
-* get date:
-SET &NOWDATE = EDIT(&YYMD,'9999/99/99');
-* concatenate date with newtime
-SET &NOWDTTM = &NOWDATE |' '| &NOWTIME;
-*dump all ampervars
-? &
-RUN
-*to use in a WHERE condition, string &NOWDTTM as one value using DT(&xx):
TABLE FILE xxxx
SUM yyyy
WHERE xDATE LE DT(&NOWDTTM);
END
-RUN


------------------------------------------
last version used: v7.1; truly miss the wonderful things I did with WebFOCUS, HTML, & JavaScript.
 
Posts: 36 | Location: Rolling Meadows, IL | Registered: September 05, 2007Report This Post
Expert
posted Hide Post
applause




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Expert
posted Hide Post
Rolling Meadows is on a roll Smiler


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Silver Member
posted Hide Post
Thank you, thank you...no applause though...just throw money... Wink...seriously though...my poor little brain is going to ooze from my ears and eyes soon Sweating . I cannot believe how much I have forgotten, yet also learned and re-learned from this forum, not to mention, the newer stuff that I didn't even know existed. I do truly appreciate all who help.


------------------------------------------
last version used: v7.1; truly miss the wonderful things I did with WebFOCUS, HTML, & JavaScript.
 
Posts: 36 | Location: Rolling Meadows, IL | Registered: September 05, 2007Report This Post
Master
posted Hide Post
I think this is pretty slick so I tried it. It did not work. At least in our environment, the 2nd parm in the HGETC function needs to be 'HHISsm' not 'HHISSM'. Once I made that change, it worked like a champ.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report This Post
Gold member
posted Hide Post
Just wanted to do the Francis dialog manager version in a couple less steps.

-SET &CUR_DTTM = HCNVRT(HGETC(8,'HYYMDs'), '(HYYMDS)', 20, 'A20');
-SET &NEW_DTTM = HCNVRT(HADD(HINPUT(14, '&CUR_DTTM.EVAL' , 14, 'HYYMDS'), 'HOUR', -8, 8, 'HYYMDS'), '(HYYMDS)', 20, 'A20');
-SET &NEW_DTTM1 = EDIT(&NEW_DTTM, '9999$99$99$99$99$99');

-TYPE Old: &CUR_DTTM / New: &NEW_DTTM or &NEW_DTTM1


version 8202M
Reporting Server on
Windows Server using DB2 Connect to access data from iseries.
 
Posts: 78 | Registered: December 29, 2009Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] How to add one hour from the date/timestamp

Copyright © 1996-2020 Information Builders