Page 1 of 1

Casting

Posted: Sun Jun 21, 2009 7:59 am
by everreadyeddie
Hi All

I am attempting to select by date from the Sage Accounts package using:

Code: Select all

SELECT * FROM F_ECRITUREC WHERE cast(CBMODIFICATION AS char) = '2009-06-20'
 
but I get:

SQL error: [Simba][Simba ODBC Driver]
SELECT * FROM F_ECRITUREC WHERE cast(CBMODIFICATION AS<< ??? >> char) = '2009-06-20'

I'm assuming CBMODIFICATION is a date object on the database as it is in YYYY-MM-DD format.

Can anyone help me?
Many thanks.

Re: Casting

Posted: Mon Jun 22, 2009 7:58 am
by patrickmvi
I'm not familiar with Sage specifically. If it shows in the database as a date and the field type is date, then you don't need to cast it at all, just do

SELECT * FROM F_ECRITUREC WHERE CBMODIFICATION = '2009-06-20'

Even if it would be a varchar or text field, this should work as well.

Re: Casting

Posted: Thu Jun 25, 2009 8:45 am
by everreadyeddie
Ah, got it. Yes that works of course.

Thanks.