如何在sql server中获得24小时到12小时的时间? [英] How to get time form 24 hs to 12 hr in sql server ?
本文介绍了如何在sql server中获得24小时到12小时的时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有桌子,因为我将一个列名称声明为DateSend作为nvarchar(10)并且我将时间存储为
10.12.11
15.45.44
¥55.00
以上表格我需要转换为12小时像
10:12:11 AM
03:45:44 PM
05:00:00 PM
什么是sql查询?
问候
Aravind
Hi
I have table,in that i declare one column name as DateSend as nvarchar(10) and i store time as
10.12.11
15.45.44
17.00.00
form above i need to convert to 12 hr like
10:12:11 AM
03:45:44 PM
05:00:00 PM
what is the sql query ?
Regards
Aravind
推荐答案
假设ur表名为table1,列为DateSend数据类型nvarchar(10)
试试这个
assuming ur table name as table1 and column as DateSend of datatype nvarchar(10)
try this
select REPLACE(CONVERT(varchar(20),CAST(REPLACE(DateSend ,'.',':') AS TIME),109),'.0000000',' ') FROM table1
祝你好运; - )
good luck ;-)
这篇关于如何在sql server中获得24小时到12小时的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文