Good way, Razzak.

A different look at it: I calculate the first date of a month by
SET VAR vStartDate = (.#DATE - IDAY(.#DATE) + 1)

There are innumerable ways to do things in R:Base.
Albert

On 30/05/2013 8:09 AM, A. Razzak Memon wrote:
Thursday, May 30, 2013

Tip of the Day: Defining First and Last Date of the Current Month
Product: R:BASE eXtreme 9.5 (32/64)
Build..: 9.5.2.20521 or higher www.rupdates.com
Section: Functions, Programming

There are times when you may need to provide your users with a pre-defined
first and last date of the month for query and/or reporting purposes.

Did you know that you can dynamically define the first and last date of
the current month by using the following two lines of code:

SET VAR vStartDate DATE = (RDATE((IMON(.#DATE)),1,(IYR4(.#DATE))))
SET VAR vEndDate DATE = ((ADDMON(.vStartDate,1))-1)

The two lines of code above will always calculate the first and last date
of the current month regardless of the current date.


Reply via email to