如何将datetime拆分为date? [英] how can i split datetime into date ?

查看:72
本文介绍了如何将datetime拆分为date?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何转换

19-jan-12 11:12:12 PM to 19-jan-12



我将日期时间存储在SqlServer数据库中

它以"19-jan-12 11:12:12 PM"格式存储
现在我想获取日期为12年1月19日的行
并绑定该数据,以便如何从数据库中检查

请迅速提供帮助

thnx



i store datetime in SqlServer Database

it stored as "19-jan-12 11:12:12 PM" format
now i want to get row whose date is 19-jan-12
and bind that data so how can i check from database

please help quickly

thnx

推荐答案

你好,

请参考
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx
另请参阅
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
hello,

please refer
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx
refer this also
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx


TextBox1.Text = DateTime.Now.ToString("dd-MM-yy");


您可以使用

you can use

dateToDisplay.ToShortDateString()



注意:ToShortDateString方法返回的字符串对区域性敏感.它反映了当前区域性的DateTimeFormatInfo对象定义的模式.例如,对于美国文化,标准的短日期模式为"M/d/yyyy";对于de-DE文化,它是"dd.MM.yyyy";对于ja-JP文化,它是"yyyy/M/d".还可以对特定计算机上的特定格式字符串进行自定义,以使其不同于标准的短日期格式字符串.

参考: http://msdn.microsoft.com/en-us/library/system. datetime.toshortdatestring.aspx [ ^ ]



NOTE : The string returned by the ToShortDateString method is culture-sensitive. It reflects the pattern defined by the current culture''s DateTimeFormatInfo object. For example, for the en-US culture, the standard short date pattern is "M/d/yyyy"; for the de-DE culture, it is "dd.MM.yyyy"; for the ja-JP culture, it is "yyyy/M/d". The specific format string on a particular computer can also be customized so that it differs from the standard short date format string.

ref : http://msdn.microsoft.com/en-us/library/system.datetime.toshortdatestring.aspx[^]


这篇关于如何将datetime拆分为date?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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