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] Adding hours to date and time fields

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Adding hours to date and time fields
 Login/Join
 
Silver Member
posted
I have date and time in two separate fields in the table.
Date in date format-YYMD (ex:2009/04/14) and time in alpha format-A15 (ex: 12.40.41.625652)
What is the best way to add 36 hours into the above date and time fields?

Thanks,
JJ

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


WebFOCUS 8.2.05
Windows 2003
Excel, HTML, PDF
 
Posts: 47 | Registered: April 22, 2009Report This Post
Expert
posted Hide Post
Here's an example, DT and TM are your date and time fields:

DEFINE FILE CAR
DT/YYMD = '2009/04/14';
TM/A15 = '12.40.41.625652';

DT1/A8YYMD = DT;
TM1/A15 = EDIT(TM,'99$:99$:999999999');
DTTM1/A24 = DT1 | ' ' | TM1;

DTTM2/HYYMDm = HADD(DT(20090414 12:40:41.625652), 'HOUR', 36, 10, 'HYYMDm'); 

END
TABLE FILE CAR
PRINT 
DT
DT1
TM
DTTM1
DTTM2

COUNTRY
END


Read up on "Using Standard Date and Time Func" in the "Using Functions" manual.

If you need to convert the last Date-time field back to individual date and time fields, you will require a couple of more defines...


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 Francis! If I replace hard coded date/time value with DTTM1 in DTTM2 define, I get an error. Below is how I changed it, am I doing something wrong?
DTTM2/HYYMDm = HADD(DT(DTTM1), 'HOUR', 36, 10, 'HYYMDm');

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


WebFOCUS 8.2.05
Windows 2003
Excel, HTML, PDF
 
Posts: 47 | Registered: April 22, 2009Report This Post
Virtuoso
posted Hide Post
Use HINPUT to convert the date and time into an 'H' field -- Its input argument can be a data field, but its values should be a straight series of digits, as below:
DEFINE FILE CAR
-* construct sample values
 DT/YYMD = '&DATEYYMD';
 TM/A15 = HHMMSS('A8') | '.987654';
 DATE/YYMD WITH COUNTRY = IF DATE EQ 0 THEN DT ELSE DATE + 1;
-* convert to suitable input for HINPUT:
 ALPHA_DT/A8YYMD=DATE;
 ALPHA_DTTM/A20= ALPHA_DT | EDIT(TM,'99$99$99$999999');
-* convert to date-time format, and add 36 hours:
 DTTM/HYYMDm=HINPUT(20,ALPHA_DTTM,10,DTTM);
 LATER/HYYMDm=HADD(DTTM, 'HOUR', 36, 10, 'HYYMDm');
END
TABLE FILE CAR
 PRINT DATE TM ALPHA_DTTM DTTM LATER 
 BY COUNTRY
END

This message has been edited. Last edited by: j.gross,


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
JJ, Sorry! I worked on test code and then posted the wrong stuff!

Jack has posted the correct solution.

My solution should have been posted as:
DEFINE FILE CAR
DT/YYMD = '2009/04/14';
TM/A15 = '12.40.41.625652';

DT1/A8YYMD = DT;
TM1/A15 = EDIT(TM,'99$99$99$999999');
DTTM1/A24 = DT1 | TM1;

DTTM2/HYYMDm = HADD(HINPUT(20,DTTM1,10,'HYYMDm'), 'HOUR', 36, 10, 'HYYMDm');

END
TABLE FILE CAR
PRINT
DT
DT1
TM
DTTM1
DTTM2

COUNTRY
END

Apologies.


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
Not a problem. Thank you to both of you.


WebFOCUS 8.2.05
Windows 2003
Excel, HTML, PDF
 
Posts: 47 | Registered: April 22, 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] Adding hours to date and time fields

Copyright © 1996-2020 Information Builders