×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Hello, Need your help converting3

## Hello, Need your help converting

(OP)

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.
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)

### RE: Hello, Need your help converting

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)

### RE: Hello, Need your help converting

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)

### RE: Hello, Need your help converting

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,

Just traded in my OLD subtlety...
for a NUance!

### RE: Hello, Need your help converting

I did it this way:

#### CODE --> @OUT

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

#### CODE --> @IN

Time(DateAdd("n", {Table.TimeIn}, Date(1900,1,1)))

#### 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, '##') 

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

Hope this helps.

Cheers
Pete

### RE: Hello, Need your help converting

(OP)
Worked very nicely.

Very much appreciated.
AJB

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!