Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] hOW CAN WE GET THE CURRENT TIME?
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] hOW CAN WE GET THE CURRENT TIME?
 Login/Join
 
Member
posted
As we get the current date by &YYMD is there way to get or compare the time with current time ?
Thanks for your help

This message has been edited. Last edited by: Kerry,
 
Posts: 26 | Registered: January 26, 2007Reply With QuoteReport This Post
Expert
posted Hide Post
&TOD




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Reply With QuoteReport This Post
Platinum Member
posted Hide Post
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.
 
Posts: 142 | Location: Adelaide South Australia | Registered: October 27, 2006Reply With QuoteReport This Post
Member
posted Hide Post
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
 
Posts: 26 | Registered: January 26, 2007Reply With QuoteReport This Post
Gold member
posted Hide Post
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.
 
Posts: 88 | Location: Seattle | Registered: March 29, 2007Reply With QuoteReport This Post
Platinum Member
posted Hide Post
try the following:
-SET &TIME = HHMMSS('A8');

OR

-SET &TIME = HHMMSS(TIME);


aix-533,websphere 5.1.1,apache-2.0,
wf 538(d), 537 (p),
==============
7.6.11 (t) aix 5312
websphere 6.1.19
apache 2.0
 
Posts: 195 | Registered: October 27, 2006Reply With QuoteReport This Post
Platinum Member
posted Hide Post
HOW IS THIS?

-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


aix-533,websphere 5.1.1,apache-2.0,
wf 538(d), 537 (p),
==============
7.6.11 (t) aix 5312
websphere 6.1.19
apache 2.0
 
Posts: 195 | Registered: October 27, 2006Reply With QuoteReport This Post
Member
posted Hide Post
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
 
Posts: 26 | Registered: January 26, 2007Reply With QuoteReport This Post
Platinum Member
posted Hide Post
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


aix-533,websphere 5.1.1,apache-2.0,
wf 538(d), 537 (p),
==============
7.6.11 (t) aix 5312
websphere 6.1.19
apache 2.0
 
Posts: 195 | Registered: October 27, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Reply With QuoteReport This Post
Platinum Member
posted Hide Post
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.

Ira


aix-533,websphere 5.1.1,apache-2.0,
wf 538(d), 537 (p),
==============
7.6.11 (t) aix 5312
websphere 6.1.19
apache 2.0
 
Posts: 195 | Registered: October 27, 2006Reply With QuoteReport This Post
Platinum Member
posted Hide Post
o yeh and forgot to mention it goes to 23:59:59


aix-533,websphere 5.1.1,apache-2.0,
wf 538(d), 537 (p),
==============
7.6.11 (t) aix 5312
websphere 6.1.19
apache 2.0
 
Posts: 195 | Registered: October 27, 2006Reply With QuoteReport This Post
Member
posted Hide Post
THANK YOU VERY MUCH. I just used '.' instead of ':' as Ira suggested and its working great.
Once again thank you very much
 
Posts: 26 | Registered: January 26, 2007Reply With QuoteReport This Post
Virtuoso
posted Hide Post
What is current time.....
on my watch it is now 19:53:30 (I live in Europe)

but when I hit the enter it is a bit later and I now my watch is a few minutes before, so I will not mis my daily train....

LOL




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, 2006Reply With QuoteReport This Post
Platinum Member
posted Hide Post
I need this exact format:

9/13/2010 9:50 AM

Can you give me the format? HHMMSS displays the seconds and I don't want that.


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
 
Posts: 106 | Registered: June 25, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
&TOD




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Something like this perhaps?
-SET &NOW = EDIT(HCNVRT(HGETC(8,'HMDYYm'),'(HMDYYSA)',30,'A30'),'9999999999999999$$$ 99');
-TYPE &NOW

Hope this helps ...


GamP

- Using AS 8.2.01 on Windows 7 - IE11.
in Focus since 1988
 
Posts: 1960 | Location: Netherlands | Registered: September 25, 2007Reply With QuoteReport This Post
Platinum Member
posted Hide Post
I prefer GamP solution; however, if you want something a little more broken up: try this

-SET &TIME = HHMMSS('A8'); 
-SET &AM_PM = IF (EDIT(&TIME ,'99') GE '13') THEN 'PM' ELSE 'AM';
-SET &TIME2 = &DATE ||(' '|EDIT(&TIME ,'99:'))||EDIT(&TIME ,'$$$99')||(' '|&AM_PM );
-TYPE &TIME2 


aix-533,websphere 5.1.1,apache-2.0,
wf 538(d), 537 (p),
==============
7.6.11 (t) aix 5312
websphere 6.1.19
apache 2.0
 
Posts: 195 | Registered: October 27, 2006Reply With QuoteReport This Post
Guru
posted Hide Post
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
 
Posts: 301 | Location: Galveston, Texas | Registered: July 07, 2004Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Thanks GamP. works great.


7.7.02
Windows
EXCEL, PDF, CSV, TEXT
 
Posts: 106 | Registered: June 25, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
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
 
Posts: 3034 | Location: Middle Tennessee [8204M Gen48 in Test&Prod] | Registered: February 23, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
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...
 
Posts: 3034 | Location: Middle Tennessee [8204M Gen48 in Test&Prod] | Registered: February 23, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
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
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Reply With QuoteReport This Post
Expert
posted Hide Post
Thanks for offering Susannah, I Sure Do... PM or Post...
 
Posts: 3034 | Location: Middle Tennessee [8204M Gen48 in Test&Prod] | Registered: February 23, 2005Reply With QuoteReport This Post
Platinum Member
posted Hide Post
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


aix-533,websphere 5.1.1,apache-2.0,
wf 538(d), 537 (p),
==============
7.6.11 (t) aix 5312
websphere 6.1.19
apache 2.0
 
Posts: 195 | Registered: October 27, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
Thanks Ira, I'll keep note of this. However, I'm really looking for a DM version...
 
Posts: 3034 | Location: Middle Tennessee [8204M Gen48 in Test&Prod] | Registered: February 23, 2005Reply With QuoteReport This Post
Virtuoso
posted Hide Post
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.

-SET &START = &YYMD | EDIT(HHMMSS('A8'),'99$99$99');
-*
-SET &COUNTER = 0 ;
-REPEAT ENDREPEAT1 100000 TIMES
-SET &COUNTER = &COUNTER + 1 ;
-ENDREPEAT1
-*
-RUN
-SET &FINISH    = &YYMD | EDIT(HHMMSS('A8'),'99$99$99');
-SET &START_DT  = HINPUT(14,'&START.EVAL',8,'HYYMDS');
-SET &FINISH_DT = HINPUT(14,'&FINISH.EVAL',8,'HYYMDS');
-SET &TIMEDIF   = HDIFF(&FINISH_DT,&START_DT,'SECOND','D10.0');
-SET &DAYS      = INT(&TIMEDIF / 86400);
-SET &HOURS     = INT(&TIMEDIF / 3600) - (&DAYS * 24);
-SET &MINUTES   = INT(&TIMEDIF / 60) - (&HOURS * 60) - (&DAYS * 24 * 60);
-SET &SECONDS   = &TIMEDIF - (&MINUTES * 60) - (&HOURS * 60 * 60) - (&DAYS * 24 * 60 * 60);
-*
-TYPE Start=&START, End=&FINISH
-TYPE Elapsed Time = &DAYS days, &HOURS hours, &MINUTES minutes, &SECONDS seconds

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Reply With QuoteReport This Post
Expert
posted Hide Post
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, Doug

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


   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Most recent: 8204 Gen 48 in Test and Production.
   Currently Available. Please contact me.
 
Posts: 3034 | Location: Middle Tennessee [8204M Gen48 in Test&Prod] | Registered: February 23, 2005Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] hOW CAN WE GET THE CURRENT TIME?

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.