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     [CLOSED] CONVERTING TIME FROM SECONDS TO HOURS AND MINUTES

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] CONVERTING TIME FROM SECONDS TO HOURS AND MINUTES
 Login/Join
 
Silver Member
posted
My time field shows as 780, I need this to convert to an HHMM field,ie 1:00 pm. I am able to find converting a date/time filed but this is just a time field. I have tried some of the suggestions on the date/time page but cannot get this to work. Any suggestions?

Thanks!

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


V. 762
Windows XP
 
Posts: 47 | Registered: December 19, 2007Report This Post
Virtuoso
posted Hide Post
Show what you tried, we can be more specific in the helping.

Obviously your field now is a number.
Is it in seconds?

780/60=13 minutes, so in time like hhmmss 00:13:00.




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, 2006Report This Post
Virtuoso
posted Hide Post
WAITSS/I6= INT( AVGWAITS/3600 ) * 10000
+ INT( IMOD(AVGWAITS,3600,'I4')/60 ) * 100 +
IMOD(AVGWAITS,60,'I2');
AVGWAIT/A5=EDIT(WAITSS,'$$99:99');


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Report This Post
Silver Member
posted Hide Post
Here is what I tried.

Define file Patient

NUMSEC/I4 = 244;
HOUR/I2 = (NUMSEC/60) ;
MIN/I2 = ((NUMSEC/60 - (HOUR *60)));
HHMMSS/I6= INT( NUMSEC/3600 ) * 10000
+ INT( IMOD(NUMSEC,3600,'I4')/60 ) * 100 +
IMOD(NUMSEC,60,'I2');

TIME/A8=EDIT(HHMMSS,'99:99:99');
WHERE APPOINT.APPOINT.FROM EQ TIME;

I did not design the database but go figure the field for the Appt Time is FROM


V. 762
Windows XP
 
Posts: 47 | Registered: December 19, 2007Report This Post
Silver Member
posted Hide Post
NUMBER (10)
and Yes my original field is a Number field. Thanks!


V. 762
Windows XP
 
Posts: 47 | Registered: December 19, 2007Report This Post
Virtuoso
posted Hide Post
Well, that seems about right to me. I took the code you provided and stuck it in a define for the car database, and the time comes out just fine. My code:
DEFINE FILE CAR
NUMSEC/I4 WITH CAR = 244;
HOUR/I2 = (NUMSEC/60) ;
MIN/I2 = ((NUMSEC/60 - (HOUR *60)));
HHMMSS/I6= INT( NUMSEC/3600 ) * 10000
         + INT( IMOD(NUMSEC,3600,'I4')/60 ) * 100
         + IMOD(NUMSEC,60,'I2');
TIME/A8=EDIT(HHMMSS,'99:99:99');
END
TABLE FILE CAR
PRINT CAR TIME
END

For every record it show the time as being 00:04:04, which corresponds perfectly with the 244 that we put into the NUMSEC field.
What exactly is your problem?


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Silver Member
posted Hide Post
quote:
DEFINE FILE CAR
NUMSEC/I4 WITH CAR = 244;
HOUR/I2 = (NUMSEC/60) ;
MIN/I2 = ((NUMSEC/60 - (HOUR *60)));
HHMMSS/I6= INT( NUMSEC/3600 ) * 10000
+ INT( IMOD(NUMSEC,3600,'I4')/60 ) * 100
+ IMOD(NUMSEC,60,'I2');
TIME/A8=EDIT(HHMMSS,'99:99:99');
END
TABLE FILE CAR
PRINT CAR TIME
END



This is what it returns.
FIRST LAST HOMEAREA HOMEPHONE DATE FROM STATUS TIME
John Doe 615 887-0000 2008/02/15 540 ACTIVE 00:00:00
Jane Doe 615 641-0000 2008/02/15 540 ACTIVE 00:00:00

Here is my Code:

DEFINE FILE PATIENT

THISDAY/YYMD = &YYMD;
TDAY/YYMD = DATEADD(THISDAY, 'BD',2 );

NUMSEC/I4 WITH PATIENT = '';
HOUR/I2 = (NUMSEC/60) ;
MIN/I2 = ((NUMSEC/60 - (HOUR *60)));
HHMMSS/I6= INT( NUMSEC/3600 ) * 10000
+ INT( IMOD(NUMSEC,3600,'I4')/60 ) * 100
+ IMOD(NUMSEC,60,'I2');
TIME/A8=EDIT(HHMMSS,'99:99:99');

END

TABLE FILE PATIENT
PRINT
'PATIENT.PATIENT.FIRST'
'PATIENT.PATIENT.LAST'
'PATIENT.PATIENT.HOMEAREA'
'PATIENT.PATIENT.HOMEPHONE'
'APPOINT.APPOINT.DATE'
'APPOINT.APPOINT.FROM'
'PATIENT.PATIENT.STATUS'
'TIME'


V. 762
Windows XP
 
Posts: 47 | Registered: December 19, 2007Report This Post
Expert
posted Hide Post
quote:
DEFINE FILE CAR
NUMSEC/I4 WITH CAR = 244;
HOUR/I2 = (NUMSEC/60) ;
MIN/I2 = ((NUMSEC/60 - (HOUR *60)));
HHMMSS/I6= INT( NUMSEC/3600 ) * 10000
+ INT( IMOD(NUMSEC,3600,'I4')/60 ) * 100
+ IMOD(NUMSEC,60,'I2');
TIME/A8=EDIT(HHMMSS,'99:99:99');
END
TABLE FILE CAR
PRINT CAR TIME
END


I get 00:04:04 as well (on 5.3.2)


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
Maybe I am not understanding how to do this. I need the time from my field FROM to populate the Converted Time field. The information is in the Field From When I do my report I need the seconds to show up in HHMMSS Where in my code do I need to make the change? Obiously my code will not be NUMSEC/I4 With Car do I need to Put NUMSSEC/I4 With Patient?


V. 762
Windows XP
 
Posts: 47 | Registered: December 19, 2007Report This Post
Silver Member
posted Hide Post
I am getting closer I put my field FROM in place of the 244 but my time for 780 printed as 00:13:00 and it should print as 1:00 pm


V. 762
Windows XP
 
Posts: 47 | Registered: December 19, 2007Report This Post
Virtuoso
posted Hide Post
Here is some code I have...no time to change to you...but you can get the idea
Surely there is a better way...
TIME1/A6 = EDIT(STARTTIME);
TIMELEFT/A2 = EDIT(TIME1,'$$99$$');
TIMERIGHT/A2 = EDIT(TIME1,'$$$$99');
TIME2/A6 = TIMELEFT | ':' | TIMERIGHT;
HRS1/I2 = EDIT(TIMELEFT);
HRS2/I2 = IF HRS1 GT 12 THEN HRS1 - 12 ELSE HRS1;
AM/A2 = IF HRS1 GE 12 THEN 'PM' ELSE 'AM';
HRS3/A2 = EDIT(HRS2);
NEWTIME/A7 = HRS3 | ':' | TIMERIGHT | AM;
MORETIME/A7 = HRS3 | ':' | '00' | AM;
THISTIME/A7 = IF MORETIME EQ '00:00AM' THEN '12:00AM' ELSE MORETIME;


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Report This Post
Expert
posted Hide Post
Here's another method, using Date-Time fields.

FILEDEF PATIENT DISK activity.txt
-RUN

-WRITE PATIENT John     Doe      615 887-0000 20080215 540 ACTIVE
-WRITE PATIENT Jane     Doe      615 641-0000 20080215 540 ACTIVE

FILEDEF MASTER DISK patient.mas
-RUN

-WRITE MASTER FILENAME=PATIENT, SUFFIX=FIX
-WRITE MASTER SEGNAME=PATIENT
-WRITE MASTER FIELDNAME=FIRST,      FORMAT=A8, ACTUAL=A8, $
-WRITE MASTER FIELDNAME=FILL1,      FORMAT=A1, ACTUAL=A1, $
-WRITE MASTER FIELDNAME=LAST,       FORMAT=A8, ACTUAL=A8, $
-WRITE MASTER FIELDNAME=FILL2,      FORMAT=A1, ACTUAL=A1, $
-WRITE MASTER FIELDNAME=HOMEAREA,   FORMAT=A3, ACTUAL=A3, $
-WRITE MASTER FIELDNAME=FILL2,      FORMAT=A1, ACTUAL=A1, $
-WRITE MASTER FIELDNAME=HOMEPHONE,  FORMAT=A8, ACTUAL=A8, $
-WRITE MASTER FIELDNAME=FILL2,      FORMAT=A1, ACTUAL=A1, $
-WRITE MASTER FIELDNAME=DATE,       FORMAT=A8YYMD, ACTUAL=A8, $
-WRITE MASTER FIELDNAME=FILL2,      FORMAT=A1, ACTUAL=A1, $
-WRITE MASTER FIELDNAME=FROMM,      FORMAT=I3, ACTUAL=A3, $
-WRITE MASTER FIELDNAME=FILL2,      FORMAT=A1, ACTUAL=A1, $
-WRITE MASTER FIELDNAME=STATUS,     FORMAT=A6, ACTUAL=A6, $
-RUN

DEFINE FILE PATIENT
CURR_DATE/HYYMD = HINPUT(14, '&YYMD.000000', 8, 'HYYMDS');
FROM_TIME/HHIS = IF FROMM GE 0 THEN HADD(CURR_DATE, 'SECOND', FROMM, 8, 'HYYMDS') ELSE CURR_DATE;
END
-RUN
TABLE FILE PATIENT
PRINT
FIRST
LAST
HOMEAREA
HOMEPHONE
DATE
FROMM
STATUS
FROM_TIME
END
-RUN


I had to rename the field FROM to FROMM - I was getting an error, it appears FROM is a reserved word.

CURR_DATE is a date-time field with the current date - this is used temporarily. The value evaluates to today's date with 0 hours minutes seconds - 2008/02/13 00:00:00.

FROM_TIME is date-time field in Hours:Minutes:Seconds format. FROMM is added to CURR_DATE to determine the time that FROMM represents. It is assumed the FROMM is the number of seconds, though I have not seen this confirmed by you. If it's minutes, then simply change SECONDS to MINUTES. This is the field you are interested in.


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
Expert
posted Hide Post
I forgot to mention that the -WRITE statements are setting up the data and Master of your PATIENT file.

Also, you can change the format HHIS to HHISa to get am/pm displayed.


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
Virtuoso
posted Hide Post
quote:
NUMSEC/I4 WITH PATIENT = '';

Maybe it helps if you equate the field NUMSEC to something that actually has a value. With the code above, the value of the field will always be 0.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Master
posted Hide Post
LOgle,

Seems to me that your time field is not a time field, but an interger representing the number of minutes not seconds. If your time field is NUMMIN and contains 780, to convert this to "01:00 pm", do the following:
HOURS/I2=NUMMIN/60;
MINUTES/I2=NUMMIN-(HOURS*60);
AMPM/A3=IF HOURS GE 12 THEN ' pm' ELSE ' am';
DHOURS/I2=IF HOURS GE 12 THEN HOURS-12 ELSE HOURS;
DTIME/A8=EDIT(DHOURS) | ':' | EDIT(MINUTES) | AMPM;

Your input shows a FROM 540, which also seems to be minutes. This would convert to 9:00 am.

Actually, you could make this a function using the DEFINE FUNCTION if you needed to do this a lot.


In FOCUS since 1985. Prod WF 8.0.08 (z90/Suse Linux) DB (Oracle 11g), Self Serv, Report Caster, WebServer Intel/Linux.
 
Posts: 975 | Location: Oklahoma City | Registered: October 27, 2006Report This Post
Silver Member
posted Hide Post
Jgelona
It Works Now! Thank you sooo very much! I did this:

Define file Patient

DTIME/A8=EDIT(DHOURS) | ':' | EDIT(MINUTES) | AMPM;

END

TABLE FILE PATIENT
PRINT
'PATIENT.PATIENT.FIRST'
'PATIENT.PATIENT.LAST'
'PATIENT.PATIENT.HOMEAREA'
'PATIENT.PATIENT.HOMEPHONE'
'APPOINT.APPOINT.DATE'
'DTIME'
'PATIENT.PATIENT.STATUS'


V. 762
Windows XP
 
Posts: 47 | Registered: December 19, 2007Report This Post
Gold member
posted Hide Post
Have a question, i'm trying to convert minutes into HH:MM:SS as well and i'm using this logic and i have found that when i set the variable NUMSEC as the original poster shows this all works however when i try to use a value from another variable which i processed earlier in the report it doesnt????

Code i'm referring to:
NUMSEC/I4 = 164;
HHMMSS/I4= INT( IMOD(NUMSEC,3600,'I4')/60 ) * 100 +IMOD(NUMSEC,60,'I2');
TIME/A8=EDIT(HHMMSS,'99:99');

output 02:44 which is what i'm looking for (without pm/am)

My Example (becuase the minutes could be dynamic....)
REPORT_MINUTES/I6 = MINS;
HHMMSS/I4= INT( IMOD(REPORT_MINUTES,3600,'I4')/60 ) * 100 +IMOD(REPORT_MINUTES,60,'I2');
TIME/A8=EDIT(HHMMSS,'99:99');

output 00:00

the value that is in report_minutes is 164, now if i manually type 164 into NUMSEC or REPORT_MINUTES it all works? is there some internal conversion going on here? i'm displaying the value of what is in report_minutes and it is indeed 164...?


WebFocus 8.02, SQL Server 2008r2
 
Posts: 51 | Registered: November 30, 2012Report This Post
Virtuoso
posted Hide Post
What's the format of your MINS field?
Maybe you meant it to be &MINS - thereby making it a DM variable?


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Gold member
posted Hide Post
quote:
our MINS fiel

hi GamP,

I have tried both integer and decimal and no luck, here is the code before i use that field:

PER/D8.2= (CNT_RECORD_AMOUNT * .9) + .5;
PER_RECORD/I8=90_PER;
PER_VALUE/I5 =IF RECORD_NUMBER EQ PER_RECORD THEN PAT_MINS ELSE 0;

-* this is where i have tried both integer and decemial
REPORT_MINUTES/D8.2 = PER_VALUE/60;

REPORT_MINUTES/I6 = MINS;
HHMMSS/I4= INT( IMOD(REPORT_MINUTES,3600,'I4')/60 ) * 100 +IMOD(REPORT_MINUTES,60,'I2');
TIME/A8=EDIT(HHMMSS,'99:99');


WebFocus 8.02, SQL Server 2008r2
 
Posts: 51 | Registered: November 30, 2012Report This Post
Expert
posted Hide Post
This seems to work for me, the correct time in minutes and seconds is calculated:

TABLE FILE CAR
PRINT
COMPUTE REPORT_MINUTES/I6 = WEIGHT;
COMPUTE HHMMSS/I4 = 
  INT( IMOD(REPORT_MINUTES,3600,'I4') / 60 ) * 100 + 
  IMOD(REPORT_MINUTES,60,'I2');
COMPUTE TIME/A5 = EDIT(HHMMSS,'99:99');
END


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
Member
posted Hide Post
If you need it as a time value so that you can sort it:
TABLE FILE CAR
PRINT 
 WEIGHT AS 'Seconds'
 COMPUTE T1/HHISa MISSING ON = HADD(DT(0), 'ss', WEIGHT, 8, T1);  AS 'Seconds as Time'
 LENGTH AS 'Minutes'
 COMPUTE T2/HHIa MISSING ON = HADD(DT(0), 'mi', LENGTH, 8, T2);  AS 'Minutes as Time'
END

Keep in mind what will happen if your times hit 24 hours or more.


WebFOCUS 7.6.7
Linux
HTML, Excel, PDF
 
Posts: 11 | Registered: February 19, 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     [CLOSED] CONVERTING TIME FROM SECONDS TO HOURS AND MINUTES

Copyright © 1996-2020 Information Builders