Joanne, there are no bad questions, only bad answers.

Use sqlite3_bind_double and your timestamp will be of type double (a 64 bit FP number),

Joanne Pham wrote:
Hi John,
Thanks for the detail info.
I am still very new to SQLite3 and sorry for the question.
My application is used C++ to insert/select the data from this table. So if I 
defined it as
  create table mytable (
  ........
 createDate REAL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (remoteWXId)
);
 Then I can use sqlite3_bind_real to bind the column but what is the datatype 
that I should use in C++ code.Do you have any example code that work for C++ in 
this case.
Sorry for the question.
Thanks,
JP


----- Original Message ----
From: John Stanton <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Monday, December 17, 2007 12:59:00 PM
Subject: Re: [sqlite] create table with datatype = DATE. SHould use as DATETIME 
or INTEGER.

Sqlite stores a date and time as a REAL so instead of trusting to manifest typing to make it a REAL your code will be easier to follow if you declare it a REAL.

Here is a simple list of the date and time functions embedded in Sqlite
1. date( timestring, modifier, modifier, ...)
        returns date as YYYY-MM-DD
    2. time( timestring, modifier, modifier, ...)
        returns time as HH:MM:SS
    3. datetime( timestring, modifier, modifier, ...)
        returns datetime as YYYY-MM-DD HH:MM:SS
    4. julianday( timestring, modifier, modifier, ...)
        returns julian day, which is a float-point number
        counting the number of days since 4714 B.C.
    5. strftime( format, timestring, modifier, modifier, ...)
        returns a string in the desired format (like printf)
    6. current_time
        returns current time as HH:MM:SS
    7. current_date
        returns current date as YYYY-MM-DD
    8. current_timestamp
        returns current timestamp as YYYY-MM-DD HH:MM:SS
ttp://www.somacon.com/p370.php

Joanne Pham wrote:
Thanks John,
" If you make it a REAL instead of DATETIME your code will be clearer." So you meant that I should make my datatype as REAL instead of DATETIME.
Thanks,
Joanne




----- Original Message ----
From: John Stanton <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Monday, December 17, 2007 10:00:11 AM
Subject: Re: [sqlite] create table with datatype = DATE. SHould use as DATETIME 
or INTEGER.

If you declared your date and time (timestamp) column DATETIME it will be floating point and will store date and time in 8 bytes. Use the FP bind function. If you make it a REAL instead of DATETIME your code will be clearer.

Joanne Pham wrote:
Hi All,
I have two question regarding DATETIME column data type:
1 ) Should I store my COLUMN as INTEGER instead of DATETIME. Is it easier if this column type is INTEGER vs DATETIME then do the conversion in the GUI code to convert from INTEGER TO DATETIME.

   2)  And if I store as DATETIME then What is the command to bind this column 
type as DATETIME.
For the INTEGER the bind command is : sqlite3_bind_int but I don't know if the column is DATETIME then what is the command to bind this column.
Thanks,
JP


----- Original Message ----
From: P Kishor <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Thursday, December 13, 2007 2:48:26 PM
Subject: Re: [sqlite] create table with datatype = DATE

CREATE TABLE test (.. createData DATETIME DEFAULT CURRENT_TIMESTAMP)

On 12/13/07, Joanne Pham <[EMAIL PROTECTED]> wrote:
Hi All,
I create the table as :
   create table test (name varchar(30), createDate DATE default 
DATETIME('NOW'));
but I got the error message. I want to have the default as now if it is not 
specify.
Thanks in advance,
Joanne


     
____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page.
http://www.yahoo.com/r/hs

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------


     
____________________________________________________________________________________
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------


      
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to