Re: [sqlite] Why does "SELECT julianday('some_date') AS dateNumber" get me a string via ODBC?

2007-06-05 Thread Trey Mack

I see that it is a variant of type VT_BSTR containing
"2345678.9123" (or whatever), and I have to use strtod() to convert it
to the number I want.  Is there a way to write the query to ensure that
it will give me a number instead of a string?


The type selection is done in your ODBC wrapper, and if it's storing that 
floating-point value as a BSTR in its returned variant, my guess is that 
it's not checking the return value from sqlite3_column_type(), and it'll 
just store everything as a BSTR. No query will change that. (The exception 
is blobs, they should be VT_ARRAY | VT_UI1).


So I would think the answer is no. Then again, I've never used the wrapper 
you're using.


- TMack


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



Re: [sqlite] Why does "SELECT julianday('some_date') AS dateNumber" get me a string via ODBC?

2007-06-05 Thread Omar Eljumaily
I believe ODBC will do type conversions for you.  If not, use sscanf.  
All sqlite data is stored as strings, I believe, anyway, so there's lots 
of type conversion going whether it's explicit or not.


Representing dates as floating point numbers can be tricky because of 
subtle rounding issues, especially when you're dealing with DST issues, 
btw.  You're better off dealing with them as Julian strings.



Rob Richardson wrote:

Greetings!

 


I am trying to talk to a small SQLite database through ADO and an ODBC
driver.  I want to convert a date to a Julian day before using the date
in a query of a table that could have over a million records.  In
SQliteSpy, the query "SELECT julianday('2007-06-05 12:34:56',
'localtime') AS dateNumber" gives me a floating-point number.  But in
ODBC, I use that query to create a recordset and examine the first value
in the recordset, I see that it is a variant of type VT_BSTR containing
"2345678.9123" (or whatever), and I have to use strtod() to convert it
to the number I want.  Is there a way to write the query to ensure that
it will give me a number instead of a string?

 


RobR

 


P.S.  Since I am going to turn around and use the value in another
query, I think I actually do want it in a string, but I'd still like to
know the answer for future reference.


  



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