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

datediff returns whole number need partial hours with decimal 1

Status
Not open for further replies.

jobillborf

Programmer
Feb 13, 2001
61
US



I would like the difference to be the total number of days with a decimal point.

In my report I am using this formula

datediff("d",{CUSTPROB.PROBDTTM},{CUSTPROB.RESDTTM});

It returns a whole number with out the partial hours.

For example instead of 10.00 days the result should be 10.10 days

.90 days are rounded up to 1.0 days. I would like the result to be .97 days.

Thanks for your help.


 
I'm assuming you are subtrating datetime type fields.

If you are, you can use:
{end.field} - {start.field}

Mike
 
If you want decimal places, you need to drop down and do a datediff by hours, then divide by 24.
Code:
(datediff("h",{CUSTPROB.PROBDTTM},{CUSTPROB.RESDTTM})/24;
When you place the formula on your report, make sure that you format it to show 2 decimal places.

~Brian
 
Using the subtraction method will give a more accurate result. For example, if you are evaluating some thing that starts at one minute after the hour and ends one minute before an hour, the elapse time is approx .04 days. If you use the ddatediff with the hour increment, it will show as .00 days.

If you still want to use the datediff function, use minutes as your increment.

datediff("n",start,end)/1440


Mike
 

Thank you for your help. I love this site.

jobillborf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top