Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Know If Month-Year Are > 6 Months Ago

Status
Not open for further replies.

JohnBates

MIS
Feb 27, 2000
1,995
US
Hi everyone,

My SQL Server database has 2 tables - 1 contains recent activity, the other contains activity/transactions that are more than 6 months old. Lets call these tables RECENT and HISTORY.

The user selects from a listbox which months data they want to view.

Then I check their selection and assign a Beg and End date for that month.... example
Case "Jan02"
BegDate = "January 2002"
EndDate = "February 2002"

I use BegDate and EndDate in my SQL Select statement...
"Select.... from Recent Where CallDate >= '" & BegDate & "'
AND CallDate < '&quot; & EndDate & &quot;'&quot;
This works perfectly, to my surprise :)

** But I need a trick to determine if BegDate is more than 6 months ago (based on current date) to determine WHICH table to select from Recent or History and that's where I'm stuck. **

Can anyone think of a way ?

Thanks for any suggestions. John






 
Have a look at the DateDiff function.

Eg.

if DateDiff(&quot;m&quot;, yourDate, Date) > 6 then...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top