如何从日期为datetime格式的数据表中选择数据 [英] How to select data from datatable where date is in datetime format

查看:65
本文介绍了如何从日期为datetime格式的数据表中选择数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我想从日期时间格式的数据表中选择数据



在我的数据网格视图中,日期是这种格式10/12/2013 12:00:32 AM



我试试这个



Hi friends,

I want to select data from datatable where date is in datetime format

In my data grid view date is this format "10/12/2013 12:00:32 AM"

I am try like this

Select DataID,Data,convert(varchar,DateCreated,103) as Date from GSMDataStore where DateCreated="+ DateTime.Today +" "





它给出了这样的错误

'12'附近的语法不正确。



请帮帮我..



提前致谢...



It gives error like this
Incorrect syntax near '12'.

Please help me..

Thanks in advance...

推荐答案

你可以查看这个



[ ^ ]
You can check this

only-retrieve-record-from-sql-database-which-have-todayss-date[^]


我想你需要在DateTime.Today周围添加单引号..这样的东西..



I think you would need to put single quote around DateTime.Today.. something like this..

"Select DataID,Data,convert(varchar,DateCreated,103) as Date from GSMDataStore where DateCreated='"+ DateTime.Today +"'"


希望这会有所帮助:



http://www.w3schools.com/sql/func_convert.asp [ ^ ]
Hope this helps:

http://www.w3schools.com/sql/func_convert.asp[^]


这篇关于如何从日期为datetime格式的数据表中选择数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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