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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DatePart

Status
Not open for further replies.

darude

Programmer
Jun 23, 2003
138
US
Good Morning All,
I have a dataset based on a job start date between 7/1 AND 8/31 for years 2006 to 2008. Jobs can be entered at any time, meaning a job could be intered in 2009 that occurred in 2007. The qualifier for my dataset is createddate < 10/1. My sql statement is below. How do I generically query the 10/1 for any given year? I'm thinking DatePart, but I'm not sure. Thank you in advance.

SELECT JobStudentID
, JobStartdate
, JobEndDate
FROM Jobs
WHERE JobSession = 'summer'
AND Year(JobstartDate) >= 2006
AND CreatedDate < '10/1'
 
Thank you for the quick response! This works as long as the created year is 2008. Jobs that occured between 7/1/2008 and 8/31/2008 can be created 2/1/2009 and greater and I don't need those in the dataset.
 
your question was "How do I generically query the 10/1 for any given year?" and my solution provides that

now you are changing the question, yes?

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
I added criteria to the question. So yes, your solution works, but not past the current year the record was created in. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top