K
Keith
Here's my function in MS SQL 2000:
ALTER FUNCTION dbo.fncDecimalHoursToHrsMins
(
@dInput DECIMAL(38,10)
)
RETURNS VARCHAR(10) AS
BEGIN
DECLARE @iMins INT
SET @iMins = ROUND((@dInput - CAST(FLOOR(@dInput) AS
DECIMAL(38,10))) * 60.00000, 0)
RETURN
(
LTRIM(RTRIM(STR(FLOOR(@dInput)))) + ':' + CASE WHEN @iMins < 10
THEN '0' ELSE '' END + LTRIM(RTRIM(STR(@iMins)))
)
END
-- end of fncDecimalHoursToHrsMins
It's been in use for a few years from an MDB and has always run fine.
For example if you enter 5.3333333 it returns 5:20 as expected. It
also runs fine from Query Analyzer. We've converted the MDB system to
an ADP system and this function does not run correctly from the ADP.
It turns the minutes into "00". So for example if you double click the
function in the ADP query window and enter 5.333333 it returns 5:00.
Any ideas?
Thanks,
Keith
ALTER FUNCTION dbo.fncDecimalHoursToHrsMins
(
@dInput DECIMAL(38,10)
)
RETURNS VARCHAR(10) AS
BEGIN
DECLARE @iMins INT
SET @iMins = ROUND((@dInput - CAST(FLOOR(@dInput) AS
DECIMAL(38,10))) * 60.00000, 0)
RETURN
(
LTRIM(RTRIM(STR(FLOOR(@dInput)))) + ':' + CASE WHEN @iMins < 10
THEN '0' ELSE '' END + LTRIM(RTRIM(STR(@iMins)))
)
END
-- end of fncDecimalHoursToHrsMins
It's been in use for a few years from an MDB and has always run fine.
For example if you enter 5.3333333 it returns 5:20 as expected. It
also runs fine from Query Analyzer. We've converted the MDB system to
an ADP system and this function does not run correctly from the ADP.
It turns the minutes into "00". So for example if you double click the
function in the ADP query window and enter 5.333333 it returns 5:00.
Any ideas?
Thanks,
Keith