Click here to Skip to main content
16,020,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

                I have  2013-02-25 18:21:39.0000000 this value in DataBase but i have to search based on Year only like 2013 or 2014, so how can I convert this field( 2013-02-25 8:21:39.0000000) into (2013)
Posted

Select DATEPART(YY,'2013-02-25 18:21:39.0000000')
 
Share this answer
 
hi,

check this.
select Year('2013-02-25 18:21:39.0000000')


it will help you,

regards,
Prakash.T
 
Share this answer
 
Hi,

Use this Query

SELECT YEAR('2013-02-25 8:21:39.0000000');

This will help you,

Regards,
Babu.K
 
Share this answer
 
Usually databases provide functions for extracting date parts, for instance SQL Server has the YEAR[^] one. See also SQL Date Functions at w3schools.com[^].
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900