Focal Point
[SOLVED] Subtract 2 minutes from datetime

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

November 21, 2011, 10:17 AM
jammer
[SOLVED] Subtract 2 minutes from datetime
-SET &TIME_STRT = HHMMSS('A8');
-SET &TIMEPART = EDIT('&TIME_STRT.EVAL','99$99$99');
-SET &TIMEPART = IF &TIMEPART.LENGTH LT 6 THEN '0' || &TIMEPART ELSE &TIMEPART ;
-SET &CURR_TS = '&YYMD.EVAL' | '&TIMEPART.EVAL' ;
-SET &CURR_TS_CONV = EDIT('&CURR_TS.EVAL','9999/99/99 99:99:99.000') ;
-TYPE Old: &CURR_TS_CONV

I looked at http://forums.informationbuild...431083832#8431083832
and tried

-SET &NEW_DTTM = HCNVRT(HADD(HINPUT(14, '&CURR_TS_CONV.EVAL' , 14, 'HYYMDS'), 'MINUTE', 5, 8, 'HYYMDS'), '(HYYMDS)', 20, 'A20');
-SET &NEW_DTTM1 = EDIT('&NEW_DTTM.EVAL', '9999/99/99 99:99:99.000');
-TYPE New: &NEW_DTTM

And I got the following incorrect result:

Old: 2011/11/21 10:13:54.000
New: 2011/11/21 10:13:05

I want
Old: 2011/11/21 10:13:54.000
New: 2011/11/21 10:11:54.000

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


Webfocus 7.6.4
Windows 2003 Server, SQL Server 2005
Excel, HTML , JavaScript ,and PDF.
Reportcaster, BID, Tomcat
November 21, 2011, 11:15 AM
Francis Mariani
-*-- Date/Time using Dialogue Manager --------------------------------------------

-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_DTTM1 = HCNVRT(HADD(HINPUT(14, '&CUR_DTTM.EVAL' , 14, 'HYYMDS'), 'MINUTE', -2, 8, 'HYYMDS'), '(HYYMDS)', 20, 'A20');

-SET &CUR_DTTM1 = EDIT(&CUR_DTTM, '9999/99/99 99:99:99');

-TYPE Old: &CUR_DTTM1
-TYPE New: &NEW_DTTM1



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
November 21, 2011, 02:17 PM
jammer
Francis,
This the same as your original post except you made it -2.

I thought I tried that and it didnt work - but I was wrong - this is indeed what I need - thanks.


Webfocus 7.6.4
Windows 2003 Server, SQL Server 2005
Excel, HTML , JavaScript ,and PDF.
Reportcaster, BID, Tomcat
November 22, 2011, 09:47 AM
DavSmith
Jammer/Francis, here is a slighlty more succinct method using HGETC to get the current date-time.

-SET &CURRENT_DTTM=HCNVRT(HGETC(20,'HYYMDS'),'(HYYMDS)',20,'A20');
-SET &NEW_DTTM=HCNVRT(HADD(HGETC(20,'HYYMDS'),'MINUTE',-2,8,'HYYMDS'),'(HYYMDS)',20,'A20');



In FOCUS since 1985 - WF 8.009/8.104 Win 8 Outputs: ALL of 'em! Adapters: Sql Server Teradata Oracle
November 22, 2011, 04:01 PM
jammer
DavSmith - thanks I will try it.


Webfocus 7.6.4
Windows 2003 Server, SQL Server 2005
Excel, HTML , JavaScript ,and PDF.
Reportcaster, BID, Tomcat