By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,842 Members | 2,440 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,842 IT Pros & Developers. It's quick & easy.

Datetime in sqlserver 2005

P: n/a
raj
Hi,

I have a table which has a column of type datetime,i want to write a
query where i can get only year from my datetime column.
2004-11-16 00:00:00.000 this is the one which i have i required only
2004 on selecting.

Thanks in Advance
Raj
Oct 9 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Wed, 8 Oct 2008 19:06:09 -0700 (PDT), raj <2r*******@gmail.com>
wrote:
>I have a table which has a column of type datetime,i want to write a
query where i can get only year from my datetime column.

2004-11-16 00:00:00.000 this is the one which i have i required only
2004 on selecting.
SELECT datepart(year,datetimecolumn)
FROM Whatever

Note that this returns an INT datatype.

Roy Harvey
Beacon Falls, CT
Oct 9 '08 #2

P: n/a
On Oct 9, 3:06*am, raj <2rajes...@gmail.comwrote:
Hi,

I have a table which has a column of type datetime,i want to write a
query where i can get only year from my datetime column.

2004-11-16 00:00:00.000 this is the one which i have i required only
2004 on selecting.

Thanks in Advance
Raj
select year(datetimecolumn) from table
Oct 10 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.