检索日期值,不显示时间戳 [英] Retreiving date value without time stamp on display
本文介绍了检索日期值,不显示时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在插入时插入的日期值为9/5/2011,在另一页上显示为9/5/2011 10:10:11.我不想显示时间.
任何的想法?请帮忙.
I am inserted in a date value which is in the form of 9/5/2011 while inserting, on displaying on the other page it showing as 9/5/2011 10:10:11. I don''t want to display the time.
Any idea? Please help.
推荐答案
取决于哪个控件,您可能会显示该值:
-在控件中格式化日期
-例如,您可以使用 DateTime.ToShortDateString方法格式化日期,然后再显示日期. [^ ]
-您可以从数据库中获取数据时删除时间部分,例如使用 CAST或CONVERT [ ^ ](如果这是Sql Server).
Depending in what control you show the value you can possibly:
- format the date in the control
- you can format the date before showing it for example using DateTime.ToShortDateString Method [^]
- you can remove the time portion when you fetch the data from the database for example by casting the value to date using using CAST or CONVERT[^] (if this is Sql Server).
使用[ ^ ]就像 yourDate.ToString("d/M/yyyy")
用于显示日期.
UseDateTime.ToString
[^] likeyourDate.ToString("d/M/yyyy")
for showing the date.
这篇关于检索日期值,不显示时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文