At 03:52 PM 3/5/2016, Kaleb Wade wrote:
I am trying to use the following for a user to provide a beginning
date (bdate)
and ending date (sdate) and a variable to be set for the same month
and day, but
for the prior year. I have exhausted every possibility I can come up
with. Any
help would be very much appreciated.
My settings are:
Date format: mm/dd/yyyy
Date sequence: mm/dd/yy
Using R:BASE X for Windows
SET VAR bdate DATE
SET VAR sdate DATE
SET VAR bdate2 DATE
SET VAR sdate2 DATE
FILLIN bdate USING 'ENTER THE BEGINNING DATE :'
FILLIN sdate USING 'ENTER THE ENDING DATE :'
SET VAR bdate2 = (RDATE((IMON(bdate)),(IDAY(bdate)),(IYR(bdate))-1))
SET VAR sdate2 = (RDATE((IMON(sdate)),(IDAY(sdate)),(IYR(sdate))-1))
Kaleb,
Here's a code that should always provide you with the
beginning/ending dates of
any given month of prior year, including the leap year.
SET VAR vBeginningDate DATE = NULL
SET VAR vEndingDate DATE = NULL
SET VAR vBeginningDate =
(ADDYR((RDATE((IMON(.#DATE)),1,(IYR(.#DATE)))),-1))
SET VAR vEndingDate = ((ADDMON(.vBeginningDate,1))-1)
And, here's a snippet of a code using the DIALOG command to ask and validate
Beginning and Ending Dates of prior year, including the leap year.
-- Start here ...
-- Get_Beginning_And_Ending_Dates.RMD
SET VAR vCaption TEXT = 'Beginning and Ending Dates'
SET VAR vBeginningDate DATE = NULL
SET VAR vEndingDate DATE = NULL
SET VAR vBeginningDate =
(ADDYR((RDATE((IMON(.#DATE)),1,(IYR(.#DATE)))),-1))
SET VAR vEndingDate = ((ADDMON(.vBeginningDate,1))-1)
LABEL GetBeginningDate
CLS
DIALOG 'Enter Beginning Date' +
vBeginningDate=23 vEndKey 1 +
CAPTION .vCaption ICON QUESTION +
OPTION WINDOW_BACK_COLOR WHITE +
|MESSAGE_BACK_COLOR WHITE +
|MESSAGE_FONT_NAME Tahoma +
|MESSAGE_FONT_COLOR RED +
|MESSAGE_FONT_SIZE 11 +
|INPUT_BACKGROUND_COLOR YELLOW +
|INPUT_FONT_NAME Tahoma +
|INPUT_FONT_COLOR RED +
|INPUT_FONT_SIZE 12 +
|BUTTON_YES_CAPTION &Continue +
|BUTTON_YES_COLOR WHITE +
|BUTTON_YES_FONT_COLOR GREEN +
|BUTTON_NO_CAPTION C&ancel +
|BUTTON_NO_COLOR WHITE +
|BUTTON_NO_FONT_COLOR RED
IF vEndKey = '[Esc]' THEN
GOTO Done
ENDIF
IF vBeginningDate IS NULL THEN
PAUSE 2 USING 'You MUST Enter Beginning Date!' +
CAPTION .vCaption ICON WARNING +
BUTTON 'Press any key to enter beginning date ...' +
OPTION BACK_COLOR WHITE +
|MESSAGE_FONT_NAME Tahoma +
|MESSAGE_FONT_COLOR RED +
|MESSAGE_FONT_SIZE 12
GOTO GetBeginningDate
ENDIF
LABEL GetEndingDate
CLS
DIALOG 'Enter Ending Date' +
vEndingDate=23 vEndKey 1 +
CAPTION .vCaption ICON QUESTION +
OPTION WINDOW_BACK_COLOR WHITE +
|MESSAGE_BACK_COLOR WHITE +
|MESSAGE_FONT_NAME Tahoma +
|MESSAGE_FONT_COLOR RED +
|MESSAGE_FONT_SIZE 11 +
|INPUT_BACKGROUND_COLOR YELLOW +
|INPUT_FONT_NAME Tahoma +
|INPUT_FONT_COLOR RED +
|INPUT_FONT_SIZE 12 +
|BUTTON_YES_CAPTION &Continue +
|BUTTON_YES_COLOR WHITE +
|BUTTON_YES_FONT_COLOR GREEN +
|BUTTON_NO_CAPTION C&ancel +
|BUTTON_NO_COLOR WHITE +
|BUTTON_NO_FONT_COLOR RED
IF vEndKey = '[Esc]' THEN
GOTO Done
ENDIF
IF vEndingDate IS NULL THEN
PAUSE 2 USING 'You MUST Enter Ending Date!' +
CAPTION .vCaption ICON WARNING +
BUTTON 'Press any key to enter ending date ...' +
OPTION BACK_COLOR WHITE +
|MESSAGE_FONT_NAME Tahoma +
|MESSAGE_FONT_COLOR RED +
|MESSAGE_FONT_SIZE 12
GOTO GetEndingDate
ENDIF
IF vEndingDate < .vBeginningDate THEN
PAUSE 2 USING 'Ending CANNOT be Prior to Beginning Date!' +
CAPTION .vCaption ICON WARNING +
BUTTON 'Press any key to enter ending date ...' +
OPTION BACK_COLOR WHITE +
|MESSAGE_FONT_NAME Tahoma +
|MESSAGE_FONT_COLOR RED +
|MESSAGE_FONT_SIZE 12
GOTO GetEndingDate
ENDIF
-- Do what you have to do here ...
LABEL Done
CLS
CLEAR VARIABLES vCaption,vBeginningDate,vEndingDate,vEndKey
RETURN
-- End here ...
Have fun!
Very Best R:egards,
Razzak.