//get doday date alone
SELECT CONVERT(varchar(8), GETDATE(), 112)
//get tomorrow date alone
SELECT CONVERT(CHAR(8), GETDATE()+1, 112)
//date diferrence in years
select datediff(year,20/3/1983,getdate())
//date difference in months
select datediff(month,20/3/1983,getdate())
//date difference in day
select datediff(day,20/3/1983,getdate())
//to add a current date with the user specified date
SELECT DATEADD(day, 30, GETDATE())
//To get the first day of the current month:
SELECT CONVERT(CHAR(10),GETDATE()+1-DAY(GETDATE()),101)
//TO display the date output like 2007/06/20
select convert(char(100),getdate(),111)
//In the above examples i used the parameter//Here I am using without Parameter.The result is like this Jun 21 2007 2:00AM
select convert(char(100),getdate())
//TO get the number of days in a current month 30
SELECT DAY(DATEADD(MONTH, 1, 1-DAY(GETDATE())+GETDATE())-1)
//TO get the current millisecon
Ans:60SELECT DATEPART(millisecond, GETDATE())
//to get the current week days
Ans: Thursday
SELECT DATENAME(WEEKDAY, GETDATE())
//Check is it a Date or Not
SELECT ISDATE('20030713') -- 1 SELECT ISDATE('2003-07-13') -- 1
select isdate(getdate())//result is 1
SELECT CONVERT(varchar(8), GETDATE(), 112)
//get tomorrow date alone
SELECT CONVERT(CHAR(8), GETDATE()+1, 112)
//date diferrence in years
select datediff(year,20/3/1983,getdate())
//date difference in months
select datediff(month,20/3/1983,getdate())
//date difference in day
select datediff(day,20/3/1983,getdate())
//to add a current date with the user specified date
SELECT DATEADD(day, 30, GETDATE())
//To get the first day of the current month:
SELECT CONVERT(CHAR(10),GETDATE()+1-DAY(GETDATE()),101)
//TO display the date output like 2007/06/20
select convert(char(100),getdate(),111)
//In the above examples i used the parameter//Here I am using without Parameter.The result is like this Jun 21 2007 2:00AM
select convert(char(100),getdate())
//TO get the number of days in a current month 30
SELECT DAY(DATEADD(MONTH, 1, 1-DAY(GETDATE())+GETDATE())-1)
//TO get the current millisecon
Ans:60SELECT DATEPART(millisecond, GETDATE())
//to get the current week days
Ans: Thursday
SELECT DATENAME(WEEKDAY, GETDATE())
//Check is it a Date or Not
SELECT ISDATE('20030713') -- 1 SELECT ISDATE('2003-07-13') -- 1
select isdate(getdate())//result is 1
No comments:
Post a Comment