Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2006
    Posts
    8

    Unanswered: help with date function

    Can anyone tell me how to caluculate a certain day of the prior month using getdate() ? The function will be hardcoded in a query that will run on either of the 1st 7 days of the month - Specifically the the 1st through the 7th day of the following month.

    ie: If it runs on April 3, I need the getdate() function to retrieve March 15th,
    if it runs on May 6, I need the getdate() function to retrieve April 15th.
    Thanks in advance for any help.

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    select dateadd(dd,14,dateadd(mm,datediff(mm,'20000101',ge tdate())-1,'20000101')) '15thPrevMth'

  3. #3
    Join Date
    Jul 2006
    Posts
    8
    That worked, thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •