Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
Sql 如何在';可读性';日期时间格式?_Sql_Sqlite_Datetime Format - Fatal编程技术网

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