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

Crystal Reports datetime Problem

Status
Not open for further replies.

njain76

IS-IT--Management
Aug 28, 2003
11
US
I have four fields

1) date1
2) time 1 - This is in long format
3) date 2
4) time2 - This is in long format

How do I find the difference in minutes between the first date and time combination and the second date and time combination.

In short x= date1 time1 - date2 time 2
How do I calculate x?

Prompt response appreciated.
Thanks
 
What do you want returned, number of days?

First combine your date and timne fields to construct a datetime (use the cdatetime function).

Crystal has the datediff function for extracting periodsfo whatever granularity you need, as in:

datediff("s",{date1formula},{date2formula})

Will give it to you in seconds. You can do it by hours, minutes, etc.

Obviously a datetime - a datetime does not equal a datetime, so you need to determine what it is that you want.

If you want something like dd:hh:mm:ss then take a look at my FAQ in the Crystal Formulas forum for converting seconds to HH:MM:SS, it can be easily tweaked to include days.

Or you can even just use a formula like:

{date1formula}-{date2formula}, which will return days.decimal, as in:

12.35 days

-k
 
I have successfully calculated the difference. Thanks for your prompt response.

I have another problem now

We have grouped the records by a particular type. Each record in each group has a date time difference (refer to previous question). We want to count the number of records in each group that have a date time difference greater than 24. Please help.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top