As we get the current date by &YYMD is there way to get or compare the time with current time ? Thanks for your helpThis message has been edited. Last edited by: Kerry,
June 26, 2007, 09:49 PM
susannah
&TOD
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
June 27, 2007, 04:40 AM
OPALTOSH
Unfortunately &TOD is static. It is set at the beginning of the current process and does not change. If you wnat the actual time at various stages during your process use the HHMMSS function as it returns the system time at the instant.
June 27, 2007, 09:59 AM
Usernani
thanks, what I actually need is if current time is let's say GE 06:00:00 and LE 08:00:00 then run the program, else do not run the program. With current date it works as I can use &YYMD but what should I use for current time? Thanks for your help
June 27, 2007, 10:00 AM
BobSh
To ensure you get the current date and time you would want to do the following either in your focexec or in edasprof.prf: SET DATETIME=CURRENT
WebFOCUS 7.7.05M, gen 144, Windows 2008 Server R2 64-bit, Tomcat 6.0.33, IIS 7.0, SQL Server, Excel 2013, PDF, HTML, FOCUS files.
-BEGINN -SET &STARTTIME = '06:00:00'; -SET &ENDTIME = '08:00:00'; -SET &TIME = HHMMSS('A8'); -IF ((&TIME GE &STARTTIME ) AND (&TIME LE &ENDTIME ))GOTO INTIME; -LBL0 -NOTINTIME -TYPE SORRY YA MISSED THE TIME ZONE -GOTO XIT -INTIME -TYPE OK YOU MADE IT ON TIME -XIT
Thanks, this is great, but I still have an issue. it seems that it does not care for the minutes. In the example that you gave me I thought it should display 'SORRY YA MISSED THE TIME ZONE' if the current time is 8:10 but it displays 'OK YOU MADE IT ON TIME' . It seems it is only conparing the hours and not minutes or seconds. Any suggestions??? Thank you very much
BEGINN -SET &STARTTIME = '06:00:00'; -SET &ENDTIME = '08:00:00'; -SET &TIME = HHMMSS('A8'); -IF ((&TIME GE &STARTTIME ) AND (&TIME LE &ENDTIME ))GOTO INTIME; -LBL0 -NOTINTIME -TYPE SORRY YA MISSED THE TIME ZONE -GOTO XIT -INTIME -TYPE OK YOU MADE IT ON TIME -XIT
June 27, 2007, 12:27 PM
ira
my mistake. i had ':' in the startdate and enddate. I should have used '.' see below...
-SET &ECHO = 'ALL'; -SET &STARTTIME = '06.00.00'; -SET &ENDTIME = '12.29.00'; -SET &TIME = HHMMSS('A8'); -TYPE &TIME -IF ((&TIME GE &STARTTIME ) AND (&TIME LE &ENDTIME ))GOTO INTIME; -NOTINTIME -TYPE SORRY YA MISSED THE TIME ZONE -GOTO XIT -INTIME -TYPE OK YOU MADE IT ON TIME -XIT
That may be because the HHMMSS function returns . not : between the hours, minutes and seconds. Your &STARTTIME and &TIME has different separators.
Try this:
-SET &ECHO=ALL;
-BEGINN
-SET &STARTTIME = '12:00:00';
-SET &ENDTIME = '14:00:00';
-SET &TIME = EDIT(HHMMSS('A8'),'99$:99$:99');
-IF ((&TIME GE &STARTTIME ) AND (&TIME LE &ENDTIME ))GOTO INTIME;
-LBL0
-NOTINTIME
-TYPE SORRY YA MISSED THE TIME ZONE
-GOTO XIT
-INTIME
-TYPE OK YOU MADE IT ON TIME
-XIT
I'm not sure if the time returned with the HHMMSS function is always in 24 hour format.
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
June 27, 2007, 01:01 PM
ira
True I could have altered to test it with ':' but quicker to go with their format and no need to add extra edit in. Glad it worked 4ya. Happy to help.
Do you need it as a variable or are you setting a display field?
If you are setting a display field then you can use:
DEFINE FILE CAR
DATETIME/HMDYYIA = HGETC(10, 'HMDYYIA');
END
TABLE FILE CAR
PRINT
DATETIME
MODEL NOPRINT
WHERE RECORDLIMIT EQ 1
END
-EXIT
Glenda
In FOCUS Since 1990 Production 8.2 Windows
September 14, 2010, 12:29 PM
Ted Michalski
Thanks GamP. works great.
7.7.02 Windows EXCEL, PDF, CSV, TEXT
September 16, 2010, 09:02 PM
Doug
Seeing that it's a function, it really doesn't matter what is within the parenthesis. I always used &TOD, just as a reference to TOD. But, even though the documentation (which is geared towards DEFINE and COMPUTE) states that it should be the OUTFIELD, anything works there. I, imho, don't see wasting the DEFINE or COMPUTE (on every row) for a semi-constant value. Use DM and the associated variable. Besides, using a "AND COMPUTE NOWTIME/A8 = HHMMSS(NOWTIME); NOPRINT" (as per F1 HELP) may cause different times to be displayed in the heading (on a very large report or when executed on a very slow system (I've seen this. Really, I did).
This was just for the fun of it, Doug
September 16, 2010, 09:04 PM
Doug
But, while I'm here talking (ok, typeing) about TIME functions. Does anyone have a TIMEDIF which is kind of like the DATEDIF, only with TIME? Great for time stamping...
September 16, 2010, 10:09 PM
susannah
yes, its for dialog manager. it measures the elapsed time of a job from start to finish and calculates the duration, you want it Doug?
In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
September 16, 2010, 10:31 PM
Doug
Thanks for offering Susannah, I Sure Do... PM or Post...
September 17, 2010, 10:04 AM
ira
Doug, try this. Ira
DEFINE FUNCTION TIMEDIFF(STRT_TIME/A8,END_TIME/A8)
-*SPLIT OUT HH MM SS; CONVERT TO 'I' FOR STRT_TIME AND END_TIME
STRT_HH/I2=EDIT(EDIT(STRT_TIME,'99'));
STRT_MM/I2=EDIT(EDIT(STRT_TIME,'$$$99'));
STRT_SS/I2=EDIT(EDIT(STRT_TIME,'$$$$$$99'));
STRT_SEC/I9=(STRT_HH * 3600)+(STRT_MM * 60) + STRT_SS ;
END_HH/I2=EDIT(EDIT(END_TIME,'99'));
END_MM/I2=EDIT(EDIT(END_TIME,'$$$99'));
END_SS/I2=EDIT(EDIT(END_TIME,'$$$$$$99'));
END_SEC/I9=(END_HH * 3600)+(END_MM * 60) + END_SS ;
DIFF_SCNDS/I9=END_SEC -STRT_SEC;
-*CONVERT BACK TO HH MM SS
HRS_DIFF/I2L=DIFF_SCNDS /3600;
MINS_DIFF/I2L = (DIFF_SCNDS - (HRS_DIFF * 3600))/60;
SECS_DIFF/I2L = (DIFF_SCNDS - (HRS_DIFF * 3600)) - (MINS_DIFF * 60);
-* FLLIP BACK TO ALPHA; ADD IN THE (COLONS) :'S
TIMEDIFF/A8=EDIT(HRS_DIFF) | ':' | EDIT(MINS_DIFF) | ':' | EDIT(SECS_DIFF);
END
-* using the car db...
DEFINE FILE CAR
STRT_TIME/A8 ='12:02:11';
END_TIME/A8 ='14:22:22';
END
TABLE FILE CAR
PRINT STRT_TIME AS 'Starting Time:' END_TIME AS 'Ending Time:'
COMPUTE ELAPSED/A8= TIMEDIFF(STRT_TIME,END_TIME); AS 'Elapsed Time:'
COUNTRY NOPRINT
IF RECORDLIMIT EQ 1
END
Thanks Ira, I'll keep note of this. However, I'm really looking for a DM version...
September 19, 2010, 05:42 PM
Dan Satchell
You could capture the date and time before and after your task and then use date-time functions to calculate the difference in seconds. I used a -REPEAT loop as my task here in order to get a meaningful time difference between start and finish.
Originally I used HDIFF to calculate the difference for DAY, HOUR, MINUTE, and SECOND, but discovered that if the start and finish times spanned the new minute mark (e.g., 13:06:57 to 13:07:03), HDIFF was returning 1 minute for the MINUTE difference instead of zero. So I decided to take the HDIFF total seconds and use Dialogue Manager to perform the remaining calculations.
This message has been edited. Last edited by: Dan Satchell,
WebFOCUS 7.7.05
June 11, 2015, 05:14 PM
Doug
OK, it's time to revisit this.
SET PAGE = NOLEAD
DEFINE FUNCTION TIMEDIFF(STRT_TIME/A8,END_TIME/A8)
-*SPLIT OUT HH MM SS; CONVERT TO 'I' FOR STRT_TIME AND END_TIME
STRT_HH/I2=EDIT(EDIT(STRT_TIME,'99'));
STRT_MM/I2=EDIT(EDIT(STRT_TIME,'$$$99'));
STRT_SS/I2=EDIT(EDIT(STRT_TIME,'$$$$$$99'));
STRT_SEC/I9=(STRT_HH * 3600)+(STRT_MM * 60) + STRT_SS ;
END_HH/I2=EDIT(EDIT(END_TIME,'99'));
END_MM/I2=EDIT(EDIT(END_TIME,'$$$99'));
END_SS/I2=EDIT(EDIT(END_TIME,'$$$$$$99'));
END_SEC/I9=(END_HH * 3600)+(END_MM * 60) + END_SS ;
DIFF_SCNDS/I9=END_SEC -STRT_SEC;
-*CONVERT BACK TO HH MM SS
HRS_DIFF/I2L=DIFF_SCNDS /3600;
MINS_DIFF/I2L = (DIFF_SCNDS - (HRS_DIFF * 3600))/60;
SECS_DIFF/I2L = (DIFF_SCNDS - (HRS_DIFF * 3600)) - (MINS_DIFF * 60);
-* FLLIP BACK TO ALPHA; ADD IN THE (COLONS) :'S
TIMEDIFF/A8=EDIT(HRS_DIFF) | ':' | EDIT(MINS_DIFF) | ':' | EDIT(SECS_DIFF);
END
DEFINE FILE CAR
STRT_TIME/A8 ='12:02:05';
END_TIME/A8 ='13:02:10';
END
TABLE FILE CAR
PRINT STRT_TIME AS 'Start Time' END_TIME AS 'End Time'
COMPUTE ELAPSED/A8= TIMEDIFF(STRT_TIME,END_TIME); AS 'Elapsed Time'
BY COUNTRY
ON TABLE SUBFOOT
"SUBFOOT: <STRT_TIME <END_TIME <ELAPSED"
ON TABLE SUBTOTAL AS 'SUBTOTAL:'
END
The above code (posted by IRA on Fri Sep 17 2010 10:04) produces this.
COUNTRY Start Time End Time Elapsed Time
ENGLAND 12:02:05 13:02:10 01:00:05
FRANCE 12:02:05 13:02:10 01:00:05
ITALY 12:02:05 13:02:10 01:00:05
JAPAN 12:02:05 13:02:10 01:00:05
W GERMANY 12:02:05 13:02:10 01:00:05
SUBTOTAL:
SUBFOOT: 12:02:05 13:02:10 01:00:05
What I need is for the "ON TABLE SUBTOTAL AS 'SUBTOTAL:'" to display the subtotals of the times. 'Elapsed Time' is 05:00:25. Or to display the time totals aligned in a SUBFOOT.
Or, a NFR which calculates time differences directly from a field which is formatted as 'HYYMDS'. This function needs to provide a result which is available in the ON TABLE or ON FIELD SUBTOTAL lines.
Let me know you thoughts and/or solution. I'll open a NFR in the meantime. Perhaps even a CASE.
Thanks in advance, DougThis message has been edited. Last edited by: Doug,
In FOCUS Since 1983 ~ from FOCUS to WebFOCUS. Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206