Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 1 of 1 total
Thread LIB - func - IsCurMonth.sql
Mon, Feb 6 2012 8:57 AMPermanent Link

Lucian

CREATE FUNCTION "IsCurMonth" (
IN "ADate" DATE)
RETURNS BOOLEAN
BEGIN
 DECLARE Result BOOLEAN DEFAULT False;
 DECLARE EndDate, StartDate DATE;
 DECLARE iYear, iMonth INTEGER;

 SET EndDate = CURRENT_DATE;
 SET iYear = EXTRACT(YEAR, EndDate);
 SET iMonth = EXTRACT(MONTH, EndDate);
 SET StartDate = CAST(CAST(iYear AS VARCHAR) + '-' + CAST(iMonth AS VARCHAR) + '-01' AS DATE);

 IF ADate BETWEEN StartDate AND EndDate THEN
   SET Result = True;
 ELSE
   SET Result = False;
 END IF;

 RETURN Result;
END

DESCRIPTION 'Boolean function to return TRUE if the given date belongs to current month.'
Image