Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    58

    Unanswered: Sql date calculation query

    Hello,

    I wonder if somebody could help me solve a problem I have. When the qry below is fired i basically want it to display data 2 weeks before the current date. So I need some form of calculation similar to the following:



    sSql1 = "select * from qryclosed where [date closed] = todays date - 14 days

    so if i launched the qry today it should pull all data with a closed date from 2/11/04 through to 15/11/04.

    I hope this makes sense.

    Thanks in advance

    Neil

  2. #2
    Join Date
    Nov 2004
    Posts
    108
    Code:
    beginDate='1/1/2004'
    endDate='1/14/2004'
    
    sSql1 = "select * from qryclosed where [date closed] between '" & beginDate & "' and '" & endDate & "'"
    you could also try looking in BOL and MSDN for datediff

    but remember that SPs are always better
    to err is human ; to really mess things up requires a computer

Posting Permissions

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