Home Varchar scalar function using decimals returns only int
Reply: 0

Varchar scalar function using decimals returns only int

user613
1#
user613 Published in May 21, 2018, 6:47 pm

I am banging my head on this one. If I execute this

SELECT CONVERT(varchar, CONVERT(datetime, 0.55), 108);

I get "13:12:00".

However, placing this into a scalar function as so

CREATE FUNCTION [dbo].[t_ExcelToTime] (@Excel decimal (12,8))
RETURNS varchar
AS
BEGIN
    DECLARE @Result varchar
    SELECT @Result =  CONVERT(varchar,CONVERT(datetime, @Excel), 108)
    RETURN @Result
END

And calling it as

SELECT [dbo].[t_ExcelToTime](0.55);

returns "1"

What am I doing wrong here?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.333286 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO