Sunday, March 11, 2012

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.

Quote:

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,getdate())|||

Quote:

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,YourDate,GETDATE()) > 14 'Two weeks before
OR DATEDIFF(day,GETDATE(), YourDate) > 14 'Two weeks after

No comments:

Post a Comment