If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Other PC Databases > SQLite - default for timestanp field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-15-08, 10:26
roli roli is offline
Registered User
 
Join Date: Jan 2005
Posts: 27
SQLite - default for timestanp field

Hi,

is it possible to create a timestamp fild in a table which uses "now" as default if i enter nothing in an insert statement? How can i do this?
Udate: my question was not complete, i dont want to insert UTC, i want to insert my local time

roli

Last edited by roli; 09-15-08 at 10:50.
Reply With Quote
  #2 (permalink)  
Old 09-15-08, 14:20
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
does the SQLite manual give you any pointers?
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 09-16-08, 05:08
roli roli is offline
Registered User
 
Join Date: Jan 2005
Posts: 27
Hi,

in the documentation i found following: "my_field TIME DEFAULT CURRENT_TIME", which uses UTC. I haven't found anything about local time.

roli
Reply With Quote
  #4 (permalink)  
Old 09-16-08, 05:52
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
classically you would record date/times in UTC/Zulu Time/GMT
then store the offset to local time.
however the manual infers you can tinker around using local time
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #5 (permalink)  
Old 09-16-08, 06:33
roli roli is offline
Registered User
 
Join Date: Jan 2005
Posts: 27
Hi,
Quote:
Originally Posted by healdem
classically you would record date/times in UTC/Zulu Time/GMT
then store the offset to local time.
ok, but this meens to switch the delay twice a year because off summer & winter time.

Quote:
Originally Posted by healdem
however the manual infers you can tinker around using local time
I read this before, but everything i tried ended with an error.

roli
Reply With Quote
  #6 (permalink)  
Old 09-16-08, 07:13
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
I'd suggest if local time is requried then you store the time as UTC/GMT and store the local time offset separately
OR
don't bother with Zulu/UTC time.

without knowing what you application is doing its hard to say what is required.

if your application is world wide, spanning several time zones then you may need to take account of local time variations. if its just a time marker its doesn't really matter.
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #7 (permalink)  
Old 09-16-08, 08:01
roli roli is offline
Registered User
 
Join Date: Jan 2005
Posts: 27
Hi,

i think i found a solution. I created the following trigger:

Code:
CREATE TRIGGER insert_localtime AFTER  INSERT ON my_tab
  BEGIN
    UPDATE my_tab SET start = TIME('NOW', 'LOCALTIME') WHERE rowid = new.rowid AND start = '';
  END
The only thing that is a bit strange to me is that my trigger don't works if i use "AND start = NULL".

Last edited by roli; 09-16-08 at 11:00. Reason: inserted code tags
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On