如何将numeric数据类型转换为datetime [英] How to convert numeric datatype to datetime

查看:849
本文介绍了如何将numeric数据类型转换为datetime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT TOP (200) Emp_ID, 
                 ProxyNo, 
                 EmpName, 
                 JoiningDate, 
                 Dept_Name, 
                 Designation, 
                 Emp_Type, 
                 Atten_date, 
                 OriginIntime, 
                 EIntime, 
                 EOutTime, 
                 Status, 
                 Shift, 
                 Overtime, 
                 OutTimeCal, 
                 TotOT,
                 RealOT, 
                 EOT, 
                 MorOT, 
                 TimeDedu, 
                 SDate, 
                 EDate, 
                 PDay, 
                 AbDay, 
                 CLDay,
                 ELDay, 
                 SLDay, 
                 WDay, 
                 FDay, 
                 WorkHrs, 
                 Pstatus, 
                 Section, 
                 Unit_Name, 
                 SubSection, 
                 ComID
FROM Temp_JobCard









在这里,我试图转换RealOT coloum。转换之前,这个coloum的数字就像是1.20。在此之后





here, I am trying to convert RealOT coloum. Before Convert this coloum had numeric which is like 1.20. After this

Here showed me <pre>1900-01-02 00:00:00.000





但是我需要显示02-01-1900 01:30。



我的目标是显示01:30。



我尝试过:



.

But i need to show 02-01-1900 01:30 .

My goal is to show 01:30 .

What I have tried:

SELECT TOP (200) Emp_ID, 
                 ProxyNo, 
                 EmpName, 
                 JoiningDate, 
                 Dept_Name, 
                 Designation, 
                 Emp_Type, 
                 Atten_date, 
                 OriginIntime, 
                 EIntime, 
                 EOutTime, 
                 Status, 
                 Shift, 
                 Overtime, 
                 OutTimeCal, 
                 TotOT, 
                 (Select convert(datetime, (convert (int, [RealOT])), 6) as 'convertedDateTime'), 
                 EOT, MorOT, 
                 TimeDedu, 
                 SDate, 
                 EDate, 
                 PDay, 
                 AbDay, 
                 CLDay, 
                 ELDay, 
                 SLDay, 
                 WDay, 
                 FDay, 
                 WorkHrs, 
                 Pstatus, 
                 Section, 
                 Unit_Name, 
                 SubSection, 
                 ComID
FROM Temp_JobCard

推荐答案

try select CONVERT(VARCHAR(5),GETDATE(),108)
in your case CONVERT(VARCHAR(5),RealOT,108) 


这篇关于如何将numeric数据类型转换为datetime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆