如何从数据库中选择数据 [英] how to select datas from database
本文介绍了如何从数据库中选择数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用查询从数据库获取数据,具体取决于datetime属性
查询就像
i used a query to get data from database depending upon the datetime property
the query was like
string sql = "select * from tblVehicle where CAST(floor( CAST( Vehentrytime AS FLOAT ) )AS DATETIME) = '" + myDate + "" + "'";
在这里,我将myDate的字符串作为
here i got the string for myDate as
string myDate = System.DateTime.Now.ToString("MM/dd/yyyy");
现在我想获取所有记录,选择一个月的数据,或者也可能是一年
我尝试过
now i want to get all records selecting datas of a month or may be year also
i tried like
string myDate = System.DateTime.Now.ToString("MM/yyyy");
但遇到错误,提示转换失败
由于我的系统时间是mm/dd/yyyy格式,我该如何获取所需的值
关于bishnu
but encountered some error saying conversion failed
since my system time is in format mm/dd/yyyy how can i obtained my desired values
with regards bishnu
推荐答案
^ ]可能会帮助您.
使用
这篇关于如何从数据库中选择数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文