如何从dateTime获取日期 [英] How to get Date from dateTime

查看:79
本文介绍了如何从dateTime获取日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:BoundField DataField="DateofBirth" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Date of Birth" />
                            <asp:boundfield datafield="DateofBirth" dataformatstring="{0:MMMM d, yyyy}" htmlencode="false" />









i我的日期从我的文本框存储到数据库12/12/1987



时我在网格视图中显示它显示日期,如12/12/1987 12:00:00 AM



i使用上面提到的dataformatting字符串。



但是我没有得到我的结果



i只需要12/12/1987,不需要时间





i am storing date from my text box to database 12/12/1987

when i papulate my grid view it display the date like this 12/12/1987 12:00:00 AM

i use above mentioned dataformatting string.

but i did not get my result

i need 12/12/1987 only, no need of time

推荐答案

更新您的查询并将此行添加到您的日期列:

Update your query and add this line to your date column:
SELECT CONVERT(nvarchar, GETDATE(), 101)





[已更新]

使用 EntityFunctions.TruncateTime方法 [ ^ ]



同时查看类似讨论:从日期时间选择日期 [ ^ ]


试一试:

Try this:
<asp:boundfield datafield="DateofBirth" xmlns:asp="#unknown">
                    HeaderText="Date of Birth" 
                    SortExpression="ModifiedDate" 
                    DataFormatString="{0:d}" /></asp:boundfield>





阅读 BoundField.DataFormatString属性 [ ^ ]





--Amit



Read BoundField.DataFormatString Property[^]


--Amit


这可能对你有帮助



代替--A-日期时间的http://stackoverflow.com/questions/6075754/how-can-you-show-the-date-in-a-gridview-as-a-date-only-instead-of -a-datetime [ ^ ]
this may help you

http://stackoverflow.com/questions/6075754/how-can-you-show-the-date-in-a-gridview-as-a-date-only-instead-of-a-datetime[^]


这篇关于如何从dateTime获取日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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