Written By:- Isha Malhotra (Software Developer)
Email:-malhotra.isha3388@gmail.com.
Note: -if you find this article helpful then kindly leave your comment
Use of DATE Function in SQL Server
When we need to play with date in sql server, in that case
we can use Date Function. Following are some function which I used in my
project:-
1. Getdate()
This function returns the current date and
time in format of ‘ yyyy-mm-dd hh:mm:ss’ where
Yyyy-year
mm-months
dd-date
hh-hour
mm-minutes
ss-Second
For example:-
select GETDATE();
2. Day(date)
This functin will return the
day part from date in numeric format.
For example:-
select DAY('2013-03-20');
this query will return 20.
3.
Year(date)
This functin will return the
year part from date in numeric format.
For example:-
select year('2013-03-20');
this query will return 2013.