LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  6 months of Start and End Dates

    Employee
    Posted 07-04-2011 09:14

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: michaelslowey

    Hi all,

    Using date() as a start date I'd like to get the start and end date of the last 6 months, not incl. this month...

    Racking my brain but cant think of where to start...I can get six dates using dateAdjust then...

    Cheers
    Mick


  • 2.  RE: 6 months of Start and End Dates

    Employee
    Posted 07-04-2011 15:17

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: henk01

    Hi Mick,

    I'm not quite sure I fully understood your question (perhaps I'm missing the point), but are you after somethings like this:

    # CurrentDate contains the date, in date format

    StartDate = date(CurrentDate.year(),CurrentDate.month(),1).dat eAdjust(-6,"months")
    EndDate = date(CurrentDate.year(),CurrentDate.month(),1).dat eAdjust(-1)


    Basically using the first of the current month as starting point, then -6 months to obtain the "StartDate", and -1 day to obtain the "EndDate"?


    Best Regards,


    Henk Thomas


  • 3.  RE: 6 months of Start and End Dates

    Employee
    Posted 07-05-2011 00:30

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: michaelslowey

    todaysDate = date()

    StartDate = date(todaysDate.year(),todaysDate.month(),1).dateA djust(-6,"months")
    EndDate = date(todaysDate.year(),todaysDate.month(),1).dateA djust(-1).dateAdjust(-5,"months")

    That does it, Thanks Henk!


  • 4.  RE: 6 months of Start and End Dates

    Employee
    Posted 07-05-2011 02:03

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: henk01

    Hi Mick,

    I guess you want to be slightly careful here with the end date, if you want the last day of the 6th month (previous).

    In that case you may want to ensure you first find the first day of the 5th month, then -1 day to obtain the last day of that previous month (i.e. last day of the 6th month).

    # todaysDate contains the date, in date format
    # and written slightly differently

    FirstOfMonth = date(todaysDate.year(),todaysDate.month(),1)

    StartDate = FirstOfMonth.dateAdjust(-6,"months")
    EndDate = FirstOfMonth.dateAdjust(-5,"months").dateAdjust(-1)


    If you test with e.g. a date in Aug-2011, I guess you�ll want a start date of 01-Feb-2011, and end date of 28-Feb-2011.


    Best Regards,

    Henk