6.6.10

DateName function in SQL Server


DateName function in SQL Server:

DateName function will be used to fetch the data/month/year/time from the datetime column.

drop table sample_table
create table sample_table (id int, dat datetime)

insert into sample_table values(1,getdate())

select * from sample_table
select id,dat from sample_table where datename(month,dat)='June'

-----------------------------------------
id dat
-----------------------------------------
1 2010-06-07 10:54:52.607
-----------------------------------------

Cheers,
Venkatesan Prabu .J
http://venkattechnicalblog.blogspot.com/

No comments:

Post a Comment