将日期时间转换为正确的格式 [英] Convert date time to proper format

查看:95
本文介绍了将日期时间转换为正确的格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何转换日期 - > 2012/12/03 11:11:04 + 22到2012/12/03 11:11:04没有拆分。我想使用(转换)。

任何解决方案?

how to convert the date-> 2012/12/03 11:11:04+22 to 2012/12/03 11:11:04 without splitting.I want to use (convert).
any solution?

推荐答案

如果你不能得到它,你必须先google然后在这里问...



You have to google first if you cant get it then ask here...

select [Date] = convert(char(10), getdate(), 111)

o/p: 2008/09/05


DateTime类有一个ToString方法,它接受一个格式字符串作为参数。

使用此功能,您可以将日期格式化为您想要的任何文本表示。



有关详细信息,请参阅此处: http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx [ ^ ]
The DateTime class has a ToString method which accepts a format string as argument.
Using this you can format the date to any text representation you want.

See here for more details: http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx[^]


DateTime.Now.ToString(MM / dd / yy)

http://www.4guysfromrolla.com/articles/111010-1.aspx [ ^ ]
DateTime.Now.ToString("MM/dd/yy")
http://www.4guysfromrolla.com/articles/111010-1.aspx[^]


这篇关于将日期时间转换为正确的格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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