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!

Round to one decimal place from two datetime values

Status
Not open for further replies.

wheels0323

Programmer
Oct 15, 2008
17
US
Need help rounding to one decimal place from two datetime fields.

So far I have.
Code:
SELECT PERSONNUM, 
ROUND(convert(decimal(10,1), datediff(minute, shiftstartdate, shiftenddate) / 65.0), 1) 
FROM VP_SCHEDULE
WHERE PERSONNUM = '016902'
AND SHIFTSTARTDATE = '2007-03-27 06:00:00.000'

That brings back a 7.8. The real value is 7.85.

So if I change the code to two decimal places, it brings back a 7.90.
Code:
SELECT PERSONNUM, 
ROUND(convert(decimal(10,2), datediff(minute, shiftstartdate, shiftenddate) / 65.0), 1) 
FROM VP_SCHEDULE
WHERE PERSONNUM = '016902'
AND SHIFTSTARTDATE = '2007-03-27 06:00:00.000'

How can I get it to come back with 7.9 only?
The shiftstarttime, and shiftendtime are datetime values.
 
You don't need to alter the way SQL returns the data. You need to alter how it is displayed in your report. In the FORMAT for your textbox, you would have:

="###,###.0#
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top