sqlite中的時間

2021-09-06 19:41:47 字數 3284 閱讀 4618

插入時間的sql語句

insert

into

[datatable

]([collectdatetime

],[channel_1

],[channel_2

],[channel_3

],[channel_4

],[channel_5

],[channel_6

],[channel_7

],[channel_8

],[channel_9

],[channel_10

],[channel_11

],[channel_12

],[channel_13

],[channel_14

],[channel_15

],[channel_16

],[channel_17

],[channel_18

],[channel_19

],[channel_20

],[channel_21

],[channel_22

],[channel_23

],[channel_24

],[channel_25

],[channel_26

],[channel_27

],[channel_28

],[channel_29

],[channel_30

],[channel_31

],[channel_32

],[channel_33

],[channel_34

],[channel_35

],[channel_36

],[channel_37

],[channel_38

],[channel_39

],[channel_40

],[channel_41

],[channel_42

],[channel_43

],[channel_44

],[channel_45

],[channel_46

],[channel_47

],[channel_48

],[channel_49

],[channel_50

],[channel_51

],[channel_52

],[channel_53

],[channel_54

],[channel_55

],[channel_56

],[channel_57

],[channel_58

],[channel_59

],[channel_60

]) values('

2014-11-17t19:37:32

','-152

','-416

','-170

','-128

','-154

','-110

','-122

','24

','-227

','-90

','-80

','-98

','-18

','-29

','120

','-29

','-71

','-50

','-76

','-128

','6

','192

','52

','140

','19

','30

','118

','19

','15

','44

','38

','-112

','-7

','-133

','-71

','-23

','-79

','-127

','-6

','-119

','232

','-101

','-146

','-309

','-127

','-212

','-181

','-152

','-62

','-68

','161

','39

','40

','87

','104

','23

','288

','21

','287

','-61

')

時間格式'2014-11-17t19:37:32'

年月日和時分秒之間多了乙個字母t,儲存到資料庫的時候,會自動給時間加8個小時。 儲存的結果為2014-11-18 03:37:32

時間格式'2014-11-17 19:37:32'  儲存到資料庫的時候,直接儲存。 儲存的結果為2014-11-17 19:37:32

使用這個語句,從資料讀取資料

sqliteconnectionstringbuilder s = new sqliteconnectionstringbuilder();

s.datasource = dbname;//dbname是包含資料庫檔名的路徑

s.datetimekind = datetimekind.local;

connectstring = s.tostring();

上面儲存的資料,讀取出來的時候,都是2014-11-17 19:37:32

但是篩選條件的時間,必須是超過2014-11-18 03:37:32,否則的話,篩選不到'2014-11-17t19:37:32'

如果注釋掉上面的語句s.datetimekind = datetimekind.local;

查詢的時候,也是同樣的效果,篩選條件的時間,必須是超過2014-11-18 03:37:32,不然也無法篩選出需要的時間

如果將s.datetimekind 設定為  s.datetimekind = datetimekind.utc;

篩選時間的時候,還是需要按照超過2014-11-18 03:37:32來篩選,讀取的時間顯示還是2014-11-17 19:37:32

鬱悶了,完全不知道設定datetimekind 的意義了

需要找個時間,專門寫個demo研究一下

datetimekind 列舉

datetime.kind 屬性

datetime.kind 屬性datetime.tostring method (string)

thisdate.tostring("s"));//會導致中間多乙個t

//s: 2008-06-15t21:15:07

SQLite中的時間日期函式

datetime 產生日期和時間 date 產生日期 time 產生時間 strftime 對以上三個函式產生的日期和時間進行格式化 datetime 的用法是 datetime 日期 時間,修正符,修正符.date 和time 的語法與datetime 相同。yyyy mm dd yyyy mm ...

SQLite 時間 查詢

datetime now 是錯的,應該是datetime now localtime 這樣才記錄手機的本地時間,不然記錄的是手機的格林威治時間。date 日期時間字串,修正符,修正符,time 日期時間字串,修正符,修正符,datetime 日期時間字串,修正符,修正符,julianday 日期時間...

SQLite 日期 時間

sqlite 支援以下五個日期和時間函式 序號函式例項1 date timestring,modifiers.以 yyyy mm dd 格式返回日期。2time timestring,modifiers.以 hh mm ss 格式返回時間。3datetime timestring,modifiers...