Date Function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Carder
    New Member
    • Jul 2007
    • 1

    #1

    Date Function

    Hello,

    How can I use the date function to search for dates 2 weeks before the system date and for 2 weeks beyond the system date and show the results.

    Can't find much in help section in access about the date function.

    Thank you.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by Paul Carder
    Hello,

    How can I use the date function to search for dates 2 weeks before the system date and for 2 weeks beyond the system date and show the results.

    Can't find much in help section in access about the date function.

    Thank you.
    try:

    select * from YourTable
    where YourDate between dateadd(d,-7,getdate()) and dateadd(d,+7,ge tdate())

    Comment

    • DonlonP
      New Member
      • Jul 2007
      • 25

      #3
      Originally posted by Paul Carder
      Hello,

      How can I use the date function to search for dates 2 weeks before the system date and for 2 weeks beyond the system date and show the results.

      Can't find much in help section in access about the date function.

      Thank you.
      Alternatively use:

      SELECT *
      FROM YourTable
      WHERE DATEDIFF(day,Yo urDate,GETDATE( )) > 14 'Two weeks before
      OR DATEDIFF(day,GE TDATE(), YourDate) > 14 'Two weeks after

      Comment

      Working...