Subject Re: [firebird-support] error formating date in stored procedure
Author jft
One avenue for you is to change the separators from "/" to "." - FB will recognise a string "16.09.2004" as a valid date, eg
SQL> select cast('16.09.2004' as date) from RDB$DATABASE;
CAST
===========
2004-09-16
or another is to retain the "/" separator and swap the month & date around, eg
SQL> select cast('09/16/2004' as date) from RDB$DATABASE;
CAST
===========
2004-09-16
Its a bit messy, but you can use the substring function to dissect & reassemble the date inside the stored procedure if there is no neater way available to you.
HTH
John
select > -------Original Message-------
> From: salenowon99 <forestsoftware@...>
> Subject: [firebird-support] error formating date in stored procedure
> Sent: 08 Aug '07 01:01
>
> Hi I'm repeatedly getting the following error message
>
> Overflow occurred during data type conversion.Conversion error from
> string "16/09/2004".
>
> when I try to run a simple stored procedure that takes a varchar(60)
> from one column in a table and then does an
>
> INSERT INTO mytable (...) VALUES (..., :str_date);
>
> to store that string as a date.
>
> now after looking through the various newsgroups and assorted posts, I
> know that I need to somehow convert that string from dd/mm/yyyy into
> mm-dd-yyyy so that firebird can understand it. (Something I've done in
> delphi more than once). But I've got no idea how to do this inside a
> firebird stored procedure. I've found lots of vague references to
> various udf functions and I've tried getting the CAST or EXTRACT
> functions to work, but with no success.
>
> I'm working on a tight deadline and I've got to get this sorted, so it
> could just be due to the fact I'm panicking that I'm missing something
> really obvious. but could some-one spell out how to do the equivalent
> of a FormatDateTime('mm-dd-yyyy',aDate) in a firebird stored procedure
> to convert a string to a date for me ??
>
> Thanks I'd be eternally grateful
>
> Chris B
>
>