Dataset.Tables("xxx").select("savdate = xxxxxxxx") [英] Dataset.Tables("xxx").select("savdate = xxxxxxxx")
问题描述
存在字段"savdate".格式为日期,保存了日期和时间.
试图从数据表中选择一个数据行,但未选择任何内容.字符串为"savdate =#5/12/2009 11:23:56#"
,在选择之前,我将日期格式的日期格式化为MM/dd/yyyy hh:mm:ss PM/AM
当我比较选择日期和数据表中的所有记录时,我发现具有该日期的数据行.
当我使用以下字符串"savdate> #5/12/2009 11:23:56#"供选择,我有一些数据行.
in the table exists the field "savdate" in format Date, there is date and time saved.
trying to select one datarow from the datatable, there's nothing selected. string is "savdate = #5/12/2009 11:23:56#"
Before selecting I formatted the date in the dateformat for english as MM/dd/yyyy hh:mm:ss PM/AM
When I compare the date for selecting and all records in datatable I found the datarow with this date.
When I used the following string "savdate > #5/12/2009 11:23:56#" for selecting, I got some datarows.
推荐答案
skolskamp,
不知道为什么将日期/时间信息另存为字符串(为什么不使用DateTime?).但是,如果您确实要查找字符串,则必须以这种方式格式化查询:
Dataset.Tables("xxx").Select("savdate ='xxxxxxxxxx'"); //请注意引号
LE:您还应注意格式化日期字符串的方式:
Hi wolfskamp,
I have no idea why you save your date/time information as a string (why not use DateTime?). But if you really look for a string you must format the query this way:
Dataset.Tables("xxx").Select("savdate='xxxxxxxxxx'"); // please note the quotes
LE: You should also pay attention to the way you format the date string:
string formattedDateString = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt", new System.Globalization.CultureInfo("en-US"));
马塞尔(Marcel)
Marcel
这篇关于Dataset.Tables("xxx").select("savdate = xxxxxxxx")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!