Casting

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
everreadyeddie
Forum Newbie
Posts: 2
Joined: Sun Jun 21, 2009 7:26 am

Casting

Post 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.
patrickmvi
Forum Commoner
Posts: 32
Joined: Mon Jun 22, 2009 6:45 am
Location: Fort Lauderdale, FL

Re: Casting

Post 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.
everreadyeddie
Forum Newbie
Posts: 2
Joined: Sun Jun 21, 2009 7:26 am

Re: Casting

Post by everreadyeddie »

Ah, got it. Yes that works of course.

Thanks.
Post Reply