SQL SERVER中的DateTime格式 [英] DateTime format in SQL SERVER

查看:89
本文介绍了SQL SERVER中的DateTime格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法以这种格式MMMM / yyyy / d ddd hh:mm:ss tt将日期时间插入sql server 2008,而我插入时我使用这种格式,但是在插入之后它的格式为 yyyy.mm.dd



任何人都可以帮助我吗?

解决方案

实际上,DateTime值是总是以相同的方式存储在Sql数据库中,它只是在Sql Manager中看到它时显示/格式化的方式或者使用查询读取它...



取决于您想要做什么,但只需将其读入DateTime变量并将其格式化为您想要的字符串:



http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx [ ^ ]


http://www.sqlusa.com/bestprac tices / datetimeconversion / [ ^ ]

您可以在sql中将列类型设置为datetime,如果需要在数据库中插入新格式的日期,请将其设置为varchar(20)并插入所需的格式。

Is there any way to insert date time in this format "MMMM/yyyy/d ddd hh:mm:ss tt" into sql server 2008 while I insert I use this format, but after I inserted it was in the format "yyyy.mm.dd"

Can anyone help me?

解决方案

Actually, a DateTime value is always stored the same way in the Sql database, it just a matter of the way it is presented/formatted when you see it in the Sql Manager or read it using a query...

Depends on what you want to do, but just read it into a DateTime variable and format it to string the way you want:

http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx[^]


http://www.sqlusa.com/bestpractices/datetimeconversion/[^]


You can make your column type in sql as datetime , also if you need to insert a new format of date in database make it as varchar(20) and insert the format that you need.


这篇关于SQL SERVER中的DateTime格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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