in reply to Binding a date in a call to an Oracle function

Try using TO_DATE(), which is an oracle function to convert a string to a date.

------
We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

  • Comment on Re: Binding a date in a call to an Oracle function

Replies are listed 'Best First'.
Re: Re: Binding a date in a call to an Oracle function
by seaver (Pilgrim) on Oct 03, 2003 at 16:39 UTC
    If you can, post the description of the table itself:

    describe table

    If the offending column is a 'datetime' column, then it will only accept 'datetime' objects, an oracle specific 'format'. Oracle doesn't care what's IN the 'datetime' objects, except that they must be a 'datetime' object. The ToDate() function dragonchild mentions converts whatever the string is into a 'datetime' object according to the /pattern/ you use in the function, for example:

    TO_DATE('01-FEB-2002' ,'dd-mon-yyyy')
    The /pattern/ MUST be able to recognise the entire string, so every string you pass in must follow the same pattern.

    Be warned, when you look for your dates in the table, they will NOT neccessarily come back to you in the same format as you declared in the TO_DATE function. This is because Oracle has its own 'datetime' format constant, which is applied to all 'datetime' formats when they are called FROM the database. This can be changed, though I forget what the constant is called.

    Cheers
    Sam