DECLARE @DATEPROMPT VARCHAR(20); 
DECLARE @DateStart DATETIME;
DECLARE @DateEnd DATETIME; 

SET @DATEPROMPT = 'CustomDateRange'; --This is a parameter in crystal "DateOption"

IF @DATEPROMPT = 'LastFullMonth'
BEGIN
    SET @DateStart =  DATEADD(MONTH, DATEDIFF(MONTH, '2013-02-01', GETDATE()), '2013-01-01');
    SET @DateEnd = DATEADD(dd, 1, DATEADD(MONTH, DATEDIFF(MONTH, '2013-02-01', GETDATE()), '2013-01-31'));
END
ELSE IF @DATEPROMPT = 'CustomDateRange'
BEGIN

    SET @DateStart = '2014-04-17';  --The date is a parameter in crystal (set default as '1999-01-01')
	SET @DateEnd = DATEADD(dd, 1, '2014-04-17');  --The date is a parameter in crystal
END


SELECT 
@DATEPROMPT,
@DateStart,
@DateEnd

 

Share This Via: