Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在SQLite表中插入日期和查询日期_Sqlite_Windows Phone 8_Windows Runtime_Microsoft Metro_Winrt Xaml - Fatal编程技术网

如何在SQLite表中插入日期和查询日期

如何在SQLite表中插入日期和查询日期,sqlite,windows-phone-8,windows-runtime,microsoft-metro,winrt-xaml,Sqlite,Windows Phone 8,Windows Runtime,Microsoft Metro,Winrt Xaml,我不熟悉SQLite的处理日期 问题是: 我可以用这种方式插入日期,也可以用DateTime来创建日期 订单日期=日期时间。今天 如何: 如何使用选择或查询记录集基本日期或订单日期 b如何根据日期范围选择或查询记录集?从这个日期到这个日期 谢谢 Class Order { [PrimaryKey, AutoIncrement] public int SId { get; set; } public int CustId { get; set;

我不熟悉SQLite的处理日期

问题是:

我可以用这种方式插入日期,也可以用DateTime来创建日期

订单日期=日期时间。今天

如何:

如何使用选择或查询记录集基本日期或订单日期

b如何根据日期范围选择或查询记录集?从这个日期到这个日期

谢谢

Class Order { [PrimaryKey, AutoIncrement] public int SId { get; set; } public int CustId { get; set; } public string No { get; set; } public string Customer { get; set; } public DateTime Order_Date { get; set; } } using (var db = new SQLite.SQLiteConnection(DBPath)) { var newOrder = new Order() { CustId = g_intCustId, Customer = txtBlkCustomer.Text.Trim(), Order_Date = DateTime.Today }; db.Insert(newOrder); ----- Update :
1) I wanted to know what is the proper way to insert date into a field of dateTime DataType in table as Above? using Date from DateTime.Today, DateTime.Now 2) what fields need to add in SQLite table when enter Date with a) normal Date format ( dd/mm/yyyy) b) format like : Date with HHMMSS 3) How to query or select Date for (2a) and (2b)? Thanks 我可以用这种方式插入日期,也可以用DateTime来创建日期。 订单日期=日期时间。今天

是的,日期时间。今天插入就可以了。SQLite在内部将日期时间对象存储为字符串

如何使用选择或查询记录集基本日期或订单日期

使用var db=new SQLite.SQLiteConnectionApplicationData.Current.LocalFolder.Path+\\aaa.SQLite { //你可以用任何一个 var list2=db.QuerySELECT*FROM Order,其中Order_Date=datetime'2013-10-01'; var list3=db.QuerySELECT*FROM Order,其中Order_Date=?,DateTime.Today.AddDays-5; } 如何根据日期范围选择或查询记录集?从这个日期到这个日期

使用var db=new SQLite.SQLiteConnectionApplicationData.Current.LocalFolder.Path+\\aaa.SQLite { //你可以用任何一个 var list=db.QuerySELECT*FROM Order,其中订单的日期介于datetime'2013-10-01'和datetime'2013-10-07'之间; var list1=db.QuerySELECT*FROM Order,其中Order_的日期介于?和?之间,DateTime.Today.AddDays-9,DateTime.Today.AddDays-3; }
通过波纹管连接


希望它能帮助你

datetime'2013-10-07'不是毫无意义吗?这将返回“2013-10-07 00:00:00”。2013-10-07 12:00:00的订单怎么样?这是无可置疑的!我使用了datetime'2013-10-07',因为OP将订单日期作为datetime传递。今天不是datetime。现在,最好使用date!并使用文字“2013-10-07”,因为函数调用没有任何作用!SQLite的日期和日期时间之间是否存在差异?文字后面必须跟年、日、月英国日期或美国日期:年、月、日。我不确定。date将只解析日期,它不接受时间。Fot文字格式请查看我是否可以在WinRT应用程序中为创建的同一个SQLite数据库同时使用SQLite Net和SQLite WinRT?@MilkBottle:是的,但我的建议是,您可以通过SQLite Client for Windows Phone.bcos使用Windows Phone 7本机数据库编程,这对您来说非常简单