在sql server 2005中将0.3(实数据类型)转换为00:30(时间) [英] convert 0.3(real datatype) into 00:30(time) in sql server 2005
本文介绍了在sql server 2005中将0.3(实数据类型)转换为00:30(时间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我在db表中有字段,在SQL 2005中有真正的数据类型。我想将其转换为时间(HH:MM)格式并添加到另一个时间。
ex:
0.3(转换为00:30)并想加入到17:45所以我可以得到18:15
0.45(转换为00:45)并想加入17:45所以我可以得到18:30
1(将其转换为01 :00)并希望加入17:45所以我可以得到18:45
谢谢。
解决方案
请阅读我对该问题的评论。
DECLARE @ rtime REAL
SET @ rtime = 0 。 3
SELECT @ rtime AS rTime, @ rtime * 60 AS RealTime,DATEADD(MINUTE , @ rtime * 60,' 2014-07-29 17:45:00') AS NewTime
Hello,
I have field in db table which have real datatype in SQL 2005. I want to convert it into time (HH:MM) format and add to another time.
ex:
0.3 (convert it to 00:30) and want to add into 17:45 so i can get 18:15
0.45(convert it to 00:45) and want to add into 17:45 so i can get 18:30
1(convert it to 01:00) and want to add into 17:45 so i can get 18:45
Thanks.
解决方案
Please, read my comment to the question.
DECLARE @rtime REAL SET @rtime = 0.3 SELECT @rtime AS rTime , @rtime *60 AS RealTime, DATEADD(MINUTE , @rtime *60, '2014-07-29 17:45:00') AS NewTime
这篇关于在sql server 2005中将0.3(实数据类型)转换为00:30(时间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文