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

Year from the date field

Status
Not open for further replies.

thendal

Programmer
Aug 23, 2000
284
Hi all!

How i can select a year alone from a datefield.


I tried


select * from tablename where datepart(year,datefieldname)='2000';

i got this going through some books ...but its not working

could some one help me ...

-ThanX
 
One common way to do this is

select * from tablename where to_char(datefieldname,yyyy)='2000';
 
Sorry, I omitted the single quotes around the 'yyyy' format.

select * from tablename where to_char(datefieldname,'yyyy')='2000';
 
Thanks karluk for the quick response ....

Thanks again

:)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top