468,242 Members | 1,444 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

Datetime in sqlserver 2005

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
2 3203
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
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.

Similar topics

3 posts views Thread by Peter Morris | last post: by
reply views Thread by brian | last post: by
2 posts views Thread by =?Utf-8?B?SmVmZnJleQ==?= | last post: by
6 posts views Thread by ad | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.