Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Number into Time

Status
Not open for further replies.

DougB13

IS-IT--Management
Aug 26, 2008
14
US
Working on a report where the time an episode starts and ends is displayed as a number field which is actually military time. I need to have the report convert it to standard time.

begin time end time
2015 2215
1125 1211
 
stringvar begint := totext({table.begintime},"0000");
time(left(begint,2),right(begint,2),0)

Create a separate formula like this for end time. Place these on the report and then go to format date->time and change the format to standard time.

-LB
 
I receive a message that too many arguments have been given for this function. Below is the formula I have.

stringvar begint := totext({visit.begin_time},"0000");
time(left(begint,2),right(begint,2),0)
 
Then I'm guessing that your field is already a string, not a number. In case the field is not always four characters, try:

stringvar begint := totext(val({visit.begin_time}),"0000");
time(left(begint,2),right(begint,2),0)

-LB
 
I believe the first formula was almost there. right(begin,2),0) was highlighted when the too many arguments message appears. The second formula does not work at all.
Thank You for your response.
 
How about...

stringvar begint := totext({visit.begin_time},"0000");
time(val(left(begint,2)),val(right(begint,2)),0)
 
That works just fine. Thank You. You wouldn't happen to know a formula to fine the difference in time?
 
Sorry, I forgot to convert it back to a number. Can we assume you are looking for the time difference within the same date? If so, you could use:

datediff("n",datetime(currentdate,{@starttime}),datetime(currentdate,{@endtime}))

This would give you the difference in minutes.

-LB
 
Thank You for your help both lbass and kskid.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top