Subject | DATE Question |
---|---|
Author | todderamaa |
Post date | 2002-05-06T17:11:48Z |
I am using Firebird 9.4.41.
I am trying to convert a DATE column to a VARCHAR(8) in a stored
procedure. What I did was create a procedure that is supposed to do
this. This stored procedure uses some UDF's from FREEUDFLIB. The
code is:
CREATE PROCEDURE DATETOSTRING (
DATEIN DATE)
RETURNS (
DATEOUT VARCHAR (8))
AS
DECLARE VARIABLE Year2 VarCHAR(4);
DECLARE VARIABLE Month2 VarCHAR(2);
DECLARE VARIABLE DayInt INTEGER;
DECLARE VARIABLE Day2 VarChar(2);
begin
/* Strip Time if in Date */
DateIn = F_StripTime(:DateIN);
Year2 = cast(f_Year(:DateIN) as CHAR(4));
Month2 = cast(F_Month(:datein) as VARCHAR(2));
DayINT = F_DayOfMonth(:datein);
Day2 = cast(:DayInt as VarChar(2));
IF(F_STRINGLENGTH(:Month2) = 1) THEN
MONTH2 = '0'||:Month2;
IF(F_STRINGLENGTH(:Day2) = 1) THEN
DAY2 = '0'||:Day2;
DateOut = :YEAR2||:MONTH2||:Day2;
suspend;
end
This procedure is called by another procedure that has retrieved a
DATE column from a table. This was working in a couple of
installations but was erroring in a third installation.
When I ran the procedure using the debugger in quickdesk I found the
error was caused by an 'AM' being in the date and so the
"F_StripTime(:DateIN)" UDF was erroring off because it didn't like the
'AM' in there.
Is there a setting somewhere to get the AM out of a date field? Or is
there a better way of achieving converting a DATE field to a
VARCHAR(8) column.
Todd
I am trying to convert a DATE column to a VARCHAR(8) in a stored
procedure. What I did was create a procedure that is supposed to do
this. This stored procedure uses some UDF's from FREEUDFLIB. The
code is:
CREATE PROCEDURE DATETOSTRING (
DATEIN DATE)
RETURNS (
DATEOUT VARCHAR (8))
AS
DECLARE VARIABLE Year2 VarCHAR(4);
DECLARE VARIABLE Month2 VarCHAR(2);
DECLARE VARIABLE DayInt INTEGER;
DECLARE VARIABLE Day2 VarChar(2);
begin
/* Strip Time if in Date */
DateIn = F_StripTime(:DateIN);
Year2 = cast(f_Year(:DateIN) as CHAR(4));
Month2 = cast(F_Month(:datein) as VARCHAR(2));
DayINT = F_DayOfMonth(:datein);
Day2 = cast(:DayInt as VarChar(2));
IF(F_STRINGLENGTH(:Month2) = 1) THEN
MONTH2 = '0'||:Month2;
IF(F_STRINGLENGTH(:Day2) = 1) THEN
DAY2 = '0'||:Day2;
DateOut = :YEAR2||:MONTH2||:Day2;
suspend;
end
This procedure is called by another procedure that has retrieved a
DATE column from a table. This was working in a couple of
installations but was erroring in a third installation.
When I ran the procedure using the debugger in quickdesk I found the
error was caused by an 'AM' being in the date and so the
"F_StripTime(:DateIN)" UDF was erroring off because it didn't like the
'AM' in there.
Is there a setting somewhere to get the AM out of a date field? Or is
there a better way of achieving converting a DATE field to a
VARCHAR(8) column.
Todd