[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Determining the Total Number of Days in a Month



     One way to do it in "pure" SQR is to:
*       Build a date that is the first day of the NEXT month.
*       Use the DateAdd function to subtract one day from it.
*       Pull out the "day" portion of the date.
*       This will always be "right" (assuming your underlying system is right -
                        if it's not, you have more serious problems anyhow)

Example:  Declare a DATE variable in the Setup section at the top of the 
program:
                        Begin-Setup
                            Begin-Declare
                                DATE $tmp_date
                            End-Decleare
                        End-Setup

                In a later procedure:
                        let $tmp_date = 
stringtodate('01-MAR-2000','DD-MON-YYYY')
                        let $tmp_date = dateadd($tmp_date,'day',-1)     [note: 
minus one]

      This will return the date of the last day in February, whatever it is.
      You can then use one of the other date functions to pull the day from the
      resulting "last day of the month" date that it will return.  Or turn it 
into a string
      with the datetostring() function and do an instring() against it.   
Whatever.

      I am not at the office, so the syntax may be a little off, but you  get 
the idea.
      This has the virtue of portability between platforms that support SQR.
      I have also found it extremely reliable over the years, easy to read, 
easy to
      maintain, easy to remember, easy, easy, easy.  I like easy.

      Enjoy,
      DennisP

-----Original Message-----
From:   Benzenhafer, Dave [SMTP:DBenzenhafer@DEEPWATER.COM]
Sent:   Monday, September 11, 2000 8:19 PM
To:     SQR-USERS@list.iex.net
Subject:        Re: Determining the Total Number of Days in a Month

I can set up an array but I am trying to come up with something that will
handle leap years or can determine the total days in any month including
February of whatever year.

-----Original Message-----
From: Sam Spritzer [mailto:sspritzer@GW.CTG.COM]
Sent: Monday, September 11, 2000 6:52 PM
To: SQR-USERS@list.iex.net
Subject: Re: Determining the Total Number of Days in a Month


You can use EVALUATE.
Sam

>>> DBenzenhafer@DEEPWATER.COM 09/11/00 18:37 PM >>>
Does any one have an easy way to determine the total of days are in a given
month?

Thanks for your help.
Dave Benzenhafer