How to Return Last month as a date range?

mickbarrs
mickbarrs Member Posts: 17
Hi All

I am trying to work out how to return last months date in the format ddmmyy..ddmmyy

Is there a quick function to return the previous month from the current month?

Cheers

Mike

Comments

  • JoeK
    JoeK Member Posts: 53
    Hi,

    thats easy, look:
    StartDate := calcdate('-CM-1M',today);
    EndDate := calcdate('-CM-1D',today);
    

    ist this what u want?

    This way u can easily work with date formulas...

    If u want a string like u described you can use this:
    OutString := strsubstno('%1..%2',StartDate, EndDate);
    

    And when u wish a "small" function use this one liner:
    OutString := strsubstno('%1..%2',calcdate('-CM-1M',today), calcdate('-CM-1D',today));
    

    Greetings
  • mickbarrs
    mickbarrs Member Posts: 17
    Works a treat, cheers Joe :)
  • JoeK
    JoeK Member Posts: 53
    mickbarrs wrote:
    Works a treat, cheers Joe :)
    No Problem ;-)