# Subtracting 2 date fields into days, hours and minutes

I am trying to subtract two DateTime fields with the results showing how many days, hours and minutes are between the two dates. For example,

02/24/03 3:10:03 - 02/23/03 9:05:45 =

1 Day 6 hours 5 min [if I am subtracting right]

Crystal keeps giving me an error that "A number is required here." by the ' Days ' portion, line 2 of formula. Can someone help?

Thanks, Laura
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
You have )'s in the wrong place

Try this

mlmcc
0
Author Commented:
Thanks, mlmcc. I'm new to this site and am not sure exactly how the points work. I only have 75.

Your corrections spit out a reponse and the number of days is correct, however, I don't think the hour and minutes portion is calculating correctly. Here is an example:

02/03/03 11:45:24AM  02/03/03 11:46:32AM and the result was
0 Days 23.00 Hours 12.00 Min. [I don't need seconds.]

The # of days is correct, but, shouldn't the hours be 0.00 and the minutes be 1.00?

Thanks, Laura
0
Commented:
Yes they should.  I assume the subtraction was in the correct order (Larger - smaller)

I don't have resources here to test with so I'll look into it in the morning.

By the way what version of CR?  Are you using Crystal or Basic syntax for the formula?

mlmcc
0
Commented:
Try this

in date time calculations m is for month n is for minutes

Datediff wil give you the number of PERIODS between the dates.  Using the modulus (MOD) function eliminates the full next higher period.  To get hours you must eliminate the full days

mlmcc
0
Author Commented:
Hi,

It finally took me a while to get back to this. I used the code directly above this comment and I am getting an error that says that a nummber or currency amount is required here and the cursor is always right before the "ToText" function. I played around with the formula and I deleted the "mod 24/60" parts and I didn't get that error, but now the hours and minutes are in the hundreds.

Thanks, Laura
0
Commented:
Sorry missed some ( )

mlmcc
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
I am being fair with this grade. I finally got an answer within a half hour of posting my finally comment. Those () did the trick!!!!!!!!!!!!!!!!!Thanks, Mlmcc.

My boss was very pleased that it only cost \$12.95 to solve this dilemma.

From Laura

THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!!
0
Commented:
No problem.  Should have seen that sooner.

mlmcc
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.