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

The result between two timevalues taking also the is not possible

Status
Not open for further replies.

thebigbadwolf

Programmer
Jul 7, 2010
67
CY
Hello,

I have two datetime fields like 01/01/2013 10:00 and 02/01/2013 09:00.

Even if I created two formulas with their timevalues, when I am trying to take the result 09:00 - 10:00 I took 23 instead of -1 (seems like the result is taking the whole field)

Is it possible to have the -1 as a result? And if yes, which formula I must use?
 
using your example and assuming {yourtable.time1} as the datetime field of 01/01/2013 10:00 and {yourtable.time2} as the datetime field of 01/01/2013 9:00 the following formula will result in -1

DateDiff ("h",{yourtable.time1},{yourtable.time1})

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
I tried this and again the result was 23. An I think is normal as this function uses the whole date field
 
if both fields are datetime fields try this

Code:
hour({yourdb.date2})-hour({yourdb.date1})
If that doesn't work reduce the formula to hour({yourdb.date2}) and verify the output is the hour portion of your field. If its not then the field may not be a datetime field.

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top