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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello, Need your help converting 3

Status
Not open for further replies.

AJB2017

IS-IT--Management
Nov 6, 2017
2
US

Hello,
Need your help converting a number into Time values and then a formula to show the difference between the two times. Basically, I am trying to display on the report how long it took between the time an item went out and when it comes back in.
Your help is greatly appreciated.
Thank you.

For Example, This is how it displays in crystal report now.

TimeOut TimeIn
997 1,086
523 596
520 680
603 650
936 1,136


This is what it should look like

TimeOut TimeIn TimeDiff(HH:MM)
04:37 PM 06:06 PM 1.69
08:43 AM 09:56 AM 1.13
08:40 AM 11:20 AM 2.08
10:03 AM 10:50 AM 0.47
03:36 PM 06:56 PM 3.02


Not sure if this helps, but ...
TimeIn Field Data type is NUMBER (in minutes from midnight)
TimeOut Field Data type is NUMBER( in minutes from midnight)

 
To get Time Out use this formula:
numbervar hr := int({yourTimeOut}/60);
numbervar mn := {yourTimeOut} mod 60;
time(hr,mn,00)

To get Time In use this formula:
numbervar hr := int({yourTimeIn}/60);
numbervar mn := {yourTimein} mod 60;
time(hr,mn,00)

To get duration HH:MM (assuming this all happens on the same day):
numbervar mns := {yourTimein}-{yourTimeOut};
totext(int(mns/60),0,"") & ":" & right("0"&totext(int(mns mod 60),0,""),2)
 
I have an extra int() function that's not needed. so ...:

To get duration HH:MM (assuming this all happens on the same day):
numbervar mns := {yourTimein}-{yourTimeOut};
totext(int(mns/60),0,"") & ":" & right("0"&totext(mns mod 60,0,""),2)
 
What you have in your first table is MINUTES.

Convert your MINUTES to DAYS in order to have values like Date/Time values, only you won't have any Date part in your values.

I'm not a CR guy, so this is an educated guess:

NewTimeIN = Time({yourTimeIn}/24/60)

You ought to be able to FORMAT your NewTime Time ValueS as hh:mm AM/PM or hh:mm military.

The Time Diff (Durtion) is merely

Diff = NewTimeOUT - NewTimeIN



Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
I did it this way:

Code:
Time(DateAdd("n", {Table.TimeOut}, Date(1900,1,1)))

[Code @IN]
Time(DateAdd("n", {Table.TimeIn}, Date(1900,1,1)))
[/Code]

[Code @DURATION]
WhilePrintingRecords;

Local NumberVar T_Minutes := {Table.TimeIn} - {Table.TimeOut};
Local NumberVar Hours := Round(T_Minutes/60, 0);
Local NumberVar Minutes := T_Minutes - (Hours*60);

ToText(Hours, '##') + ':' + ToText(Minutes, '##')
[/Code]

Format {@OUT} & {@IN) as Time.

Hope this helps.

Cheers
Pete
 
Worked very nicely.
Thank you very much for your time and sharing your expertise.

Very much appreciated.
AJB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top