Subject Re: [IBDI] SQL Date Question
Author Jacco Hotel Concepts
For older versions of IB it is also possible.

A "pure" SQL solution is also possible

You can build nice stored procs the do the work of making the dates:

CREATE PROCEDURE get_month_dates(
MONTH INT, YEAR INT
) RETURNS (MONTH_DATE DATE) AS
DECLARE VARIABLE DATE1 DATE;
DECLARE VARIABLE DATE2 DATE;
DECLARE VARIABLE MON1 CHAR(3);
DECLARE VARIABLE MON2 CHAR(3);
DECLARE VARIABLE YEAR2 INT;
BEGIN
IF (month = 1) THEN BEGIN MON1 = "JAN"; MON2 = "FEB"; END
IF (month = 2) THEN BEGIN MON1 = "FEB"; MON2 = "MAR"; END
IF (month = 3) THEN BEGIN MON1 = "MAR"; MON2 = "APR"; END
IF (month = 4) THEN BEGIN MON1 = "APR"; MON2 = "MAY"; END
IF (month = 5) THEN BEGIN MON1 = "MAY"; MON2 = "JUN"; END
IF (month = 6) THEN BEGIN MON1 = "JUN"; MON2 = "JUL"; END
IF (month = 7) THEN BEGIN MON1 = "JUL"; MON2 = "AUG"; END
IF (month = 8) THEN BEGIN MON1 = "AUG"; MON2 = "SEP"; END
IF (month = 9) THEN BEGIN MON1 = "SEP"; MON2 = "OCT"; END
IF (month = 10) THEN BEGIN MON1 = "OCT"; MON2 = "NOV"; END
IF (month = 11) THEN BEGIN MON1 = "NOV"; MON2 = "DEC"; END
IF (month = 12) THEN BEGIN MON1 = "DEC"; MON2 = "JAN"; END
YEAR2 = YEAR;
IF (MON2 = "JAN") THEN YEAR2 = YEAR2 + 1;
DATE1 = CAST("1" || "-" || MON1 || "-" || CAST(YEAR AS CHAR(4)) AS DATE);
DATE2 = CAST("1" || "-" || MON2 || "-" || CAST(YEAR2 AS CHAR(4)) AS DATE);
DATE2 = DATE2 - 1;
MONTH_DATE = DATE1;
WHILE (MONTH_DATE <= DATE2) DO BEGIN
SUSPEND;
MONTH_DATE = MONTH_DATE + 1;
END
END

The you can use a query like:

select
*
from
mytable
where
mytable_date in (select month_date from get_month_dates(5,2000))

Hotel Concepts R&D
Jacco Kulman
Jacco@...

WWW.HotelConcepts.COM
Veerdijk 40d
1531 MS WORMER
The Netherlands
tel: +31-75-621 15 51
fax: +31-75-628 93 64
----- Original Message -----
From: <gerbreown@...>
To: <IBDI@egroups.com>
Sent: donderdag 17 augustus 2000 16:13
Subject: [IBDI] SQL Date Question


> Hi All,
>
> I'm not sure if this is the correct place to post this so if it is
> not
> then I would appreciate it if I could be pointed to the correct place.
>
> My question is: How do I select records in an IB table where the
> month and year of a date field = 8 and 2000 respectivaly.
>
> I have tried MONTH(field), DATEPART("m", field), EXTRACT MONTH FROM
> field and none of these functions work in IB.
>
> TIA,
>
> Gerald S. Brown
>
>
>
>
> Community email addresses:
> Post message: IBDI@onelist.com
> Subscribe: IBDI-subscribe@onelist.com
> Unsubscribe: IBDI-unsubscribe@onelist.com
> List owner: IBDI-owner@onelist.com
>
> Shortcut URL to this page:
> http://www.onelist.com/community/IBDI
>
>