first and last date of previous month

sreekuax

Member
Hello ,

I need to extract some data based on date range. The condition is if I schedule run of the extract program 3rd of every month the date range should be last months 1st day and last day. i.e If I am running the program in 3rd feb the date range should be 1st jan and 31st jan.
How I can get this in progress.

Thanks
 

Cringer

ProgressTalk.com Moderator
Staff member
To get the last day of a month, take the 1st day of the month after and subtract 1.
You will need to look at the MONTH(), DAY(), YEAR() and DATE() functions. You should be able to work out the 1st of a month yourself.
I suggest searching the forums here too because I'm sure we've solved it before.

Edit: have a look at the ADD-INTERVAL() function too.
 

SergioC

Member
Hi, try it.

Code:
DEFINE VARIABLE d-fecha AS DATE INITIAL 04/03/2012.
                                                   /*   MM/DD/YYYY */
DISPLAY
    d-fecha                                       /* SOME-DATE */
    DAY(d-fecha)                               /* DAY-SOME-DATE */


    d-fecha - (DAY(d-fecha) +
               DAY(d-fecha - DAY(d-fecha))) + 1 /* FROM-DATE */


    d-fecha - DAY(d-fecha)                          /* TO-DATE */.

Regards.
 

sreekuax

Member
Hi, try it.

Code:
DEFINE VARIABLE d-fecha AS DATE INITIAL 04/03/2012.
                                                   /*   MM/DD/YYYY */
DISPLAY
    d-fecha                                       /* SOME-DATE */
    DAY(d-fecha)                               /* DAY-SOME-DATE */


    d-fecha - (DAY(d-fecha) +
               DAY(d-fecha - DAY(d-fecha))) + 1 /* FROM-DATE */


    d-fecha - DAY(d-fecha)                          /* TO-DATE */.

Regards.

Coool ... Thanks Sergio.. :)
 
Top