Focal Point
[CLOSED] Adding a time to a date field

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

July 06, 2015, 08:47 AM
Hero
[CLOSED] Adding a time to a date field
Hello experts,
I have a table that contains a date field and a time field
examples:
Date/HYYMDs (2003/01/02 00:00:00.000)
Time/A5 (13:23)

Is there an easy way to add the two so I woud get
a new date field (2003/01/02 13:23:00.000) ?

This message has been edited. Last edited by: <Kathryn Henning>,


WebFocus 7.611
WebFocus 7.703
Windows, All Outputs
July 06, 2015, 09:15 AM
SWES
Hello Hero,

These are really the basics of WebFOCUS you are asking for and that is not what this forum is meant for.

Please look into 'Concatenating Character Strings' (found in Help function Developer Studio for example). Also, see if you are able to follow an Information Builders course to get you started with the product.


WebFOCUS 8105m
Windows 7, All Outputs

Member of the Benelux Usergroup
July 06, 2015, 09:25 AM
Francis Mariani
There are several ways to do this - here's one of them: convert the 'time' field to numeric number of minutes, then add it to the 'date' field:

DEFINE FILE CAR
DATE1/HYYMDs WITH COUNTRY = HINPUT(8, '20030102', 8, 'HYYMDs');
TIME1/A5 = '13:23';
END

TABLE FILE CAR
PRINT
DATE1
TIME1

COMPUTE TIME1_HM/I6 = ( EDIT( EDIT(TIME1,'99$$$') ) * 60 ) +  EDIT( EDIT(TIME1,'$$$99') ); NOPRINT

COMPUTE DATE2/HYYMDs = HADD(DATE1, 'MINUTE', TIME1_HM, 8, 'HYYMDs');

WHERE RECORDLIMIT EQ 1
END

Line 11: Use EDIT to extract the Hours, convert it to numeric using another EDIT, then multiply it by 60 minutes, then use EDIT to extract the Minutes, convert it to numeric using another EDIT, then add it to the converted Hours.


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
July 06, 2015, 05:47 PM
Tony A
Also check out the HMASK function.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10