Sql 如何在';可读性';日期时间格式?
我正在使用Sql 如何在';可读性';日期时间格式?,sql,sqlite,datetime-format,Sql,Sqlite,Datetime Format,我正在使用System.Data.SQLite组件。我在Logged列中将日期时间值保存为记号。e、 g.使用c# 保存在SomeTable.Logged中的示例值为: DateTime.Now.Ticks; 如何使用sql在“正常”日期中显示此内容?e、 g.'01-05-2011 13:45:22' 我知道这一页,但我不能让事情按我想要的方式进行 试试看: 634399267463299880 其中: SELECT strftime('%Y-%m-%d %H:%M:%S',
System.Data.SQLite
组件。我在Logged
列中将日期时间值保存为记号。e、 g.使用c#
保存在SomeTable.Logged
中的示例值为:
DateTime.Now.Ticks;
如何使用sql在“正常”日期中显示此内容?e、 g.'01-05-2011 13:45:22'
我知道这一页,但我不能让事情按我想要的方式进行 试试看:
634399267463299880
其中:
SELECT strftime('%Y-%m-%d %H:%M:%S',
SomeTable.Logged/10000000 - 62135596800,
'unixepoch')
例如:
62135596800 = DateTime(1970, 1, 1, 0, 0, 0).Ticks/10000000
= number of seconds elapsed from 01/01/0001 00:00:00
until 01/01/1970 00:00:00;
=> SomeTable.Logged/10000000 - 62135596800
= number of seconds elapsed from 01/01/1970 00:00:00
until your date
=> 'unixepoch' to convert it to date value
=> '%Y-%m-%d %H:%M:%S' to format
您知道SQLLite.net是否将它们存储为记号,以便能够使用DateTimeOffset和DateTime吗?还是一种表演?
62135596800 = DateTime(1970, 1, 1, 0, 0, 0).Ticks/10000000
= number of seconds elapsed from 01/01/0001 00:00:00
until 01/01/1970 00:00:00;
=> SomeTable.Logged/10000000 - 62135596800
= number of seconds elapsed from 01/01/1970 00:00:00
until your date
=> 'unixepoch' to convert it to date value
=> '%Y-%m-%d %H:%M:%S' to format
SELECT strftime('%Y-%m-%d %H:%M:%S',
634398543220000000/10000000 - 62135596800,
'unixepoch')
==> 2011-05-01 13:45:22