您的位置:首页 > 数据库

How to write to TO CHAR and TO DATE SQL SERVER

2012-01-31 15:07 274 查看
Select convert(char,EMPJOINDATE,101) as EMPJOINDATE FROM emp;

Additionally, here is how to retrieve the current date and the formats

select convert(char, getdate(), 100) --mon dd yyyy hh:mmAM (or PM)

select convert(char, getdate(), 101) --mm/dd/yyyy

select convert(char, getdate(), 102)
--yyyy.mm.dd

select convert(char, getdate(), 103) --dd/mm/yyyy

select convert(char, getdate(), 104) --dd.mm.yyyy

select convert(char, getdate(), 105) --dd-mm-yyyy

select convert(char, getdate(), 106) --dd mon yyyy

select convert(char, getdate(), 107) --mon dd, yyyy

select convert(char, getdate(), 108) --hh:mm:ss

select convert(char, getdate(), 109) --mon dd yyyy hh:mm:ss:mmmAM (or PM)

select convert(char, getdate(), 110) --mm-dd-yyyy

select convert(char, getdate(), 111) --yyyy/mm/dd

select convert(char, getdate(), 112) --yyyymmdd

select convert(char, getdate(), 113) --dd mon yyyy hh:mm:ss:mmm

select convert(char, getdate(), 114) --hh:mm:ss:mmm(24h)

select convert(char, getdate(), 120) --yyyy-mm-dd hh:mm:ss(24h)

select convert(char, getdate(), 121) --yyyy-mm-dd hh:mm:ss.mmm
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: