【发布时间】:2017-01-03 18:17:50
【问题描述】:
我正在使用以下代码:
使用 new SQLite.Net.SQLiteConnection(new SQLitePlatformWinRT(), DBPath) 获取 SQLiteConnection 并创建表。
类包含 DateTime 数据类型
class Transaction
{
[SQLite.Net.Attributes.PrimaryKey, SQLite.Net.Attributes.AutoIncrement]
public int QId { get; set; }
public DateTime PurchaseDate { get; set; }
public int Amount {get;set;}
Public string ItemCode {get;set;}
}
插入数据如下:
var db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), DBPath);
var newItem = new Transaction()
{
PurchaseDate = DateTime.Now,
Amount = 100,
ItemCode = "Abc-C10"
};
db.Insert(newItem);
日期将存储为刻度(例如 636071680313888433),这是 UTC 时间。
1) 使用上面的 DateTime.Now,如果我的电脑时间设置是
1a) 在英国时间,
上面的代码:purchase = DateTime.Now 能正确转换吗?
1b) 在美国时间,
上面的代码:purchase = DateTime.Now 能正确转换吗?
如何在 SQL 语句中处理这个刻度?
如何从某个日期范围内选择所有交易?比如,2016-07-10 到 2016-07-20?
谢谢
【问题讨论】:
-
“正确转换”是什么意思?最正确的行为是没有转化。
标签: sqlite winrt-xaml uwp