I'm trying to get the output of the variable "ResTime" to come out in
a format like 2.45

Instead, the following code rounds the number like 2.00

<%
StartDate = rs.fields.item("Date_Created").value
EndDate = rs.fields.item("Date_Closed").value
ResTime = FormatNumber(Cdbl(DateDiff("h",StartDate,EndDate)),2)
%>

I am able to get the desired result (no rounding) by using...

Convert(decimal(10,2), (datediff(hour, [date_Created], [date_closed]))

...directly in a SQL query. But the way my ASP page works, I really
want to be able to manipulate and calculate the variables in VBScript
after the query is run.

Any suggestions? Thanks,

Russell

Re: How to prevent calculated variables from rounding? by dlbjr

dlbjr
Thu Feb 26 16:31:44 CST 2004

<SCRIPT language="vbscript" runat="server">
Function GetHoursDiff(dtmStamp1,dtmStamp2)
GetHoursDiff = 0
If IsDate(dtmStamp1) And IsDate(dtmStamp2) Then
GetHoursDiff = Abs(DateDiff("s",dtmStamp1,dtmStamp2))/3600
End If
End Function
</SCRIPT>
<%
StartDate = rs.fields.item("Date_Created").value
EndDate = rs.fields.item("Date_Closed").value
ResTime = FormatNumber(GetHoursDiff(StartDate,EndDate),2)
%>


-dlbjr

Discerning resolutions for the alms