If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > smalldatetime query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-20-05, 09:28
donaldt donaldt is offline
Registered User
 
Join Date: Jan 2002
Location: Nottingham - UK
Posts: 113
smalldatetime query

Hi Folks

Im using SQL 2000.

Is it possible to have a query that does the following....

select * where myDate = current year

I am wanting to display results purely from the current year automatically.

Any pointers will be great.

Thanks all
Reply With Quote
  #2 (permalink)  
Old 12-20-05, 10:22
mbreti mbreti is offline
Registered User
 
Join Date: Dec 2005
Posts: 1
Hello donaldt

As I understood, you would like to query the data based on year.
Since Northwind database comes with all the copies of SQL server 2000, I will use that database to do this query.

--------------------------------------------------------
USE Northwind

SELECT * FROM Employees WHERE YEAR(HireDate) = '1993'

--------------------------------------------------------

I hope this answer helped you on your project. If you have problems understanding something, I will be glad to assist you.

All the best,
Reply With Quote
  #3 (permalink)  
Old 12-21-05, 03:23
Jelly Link Jelly Link is offline
Registered User
 
Join Date: Dec 2003
Posts: 39
select * from table_name where year(myDate) = year(getdate())
-- or
select * from table_name where datediff(year,myDate,getdate())=0
__________________
Link Link
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On