Tuesday, June 5, 2007

SQL DATEDIFF Function

Returns the number of date and time boundaries crossed between two dates

SQL DATEDIFF Syntax
DATEDIFF ( DatePart , StartDate , EndDate )

DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate ='2007-06-05'
SET @EndDate ='2007-08-05'

SELECT DATEDIFF(Year, @StartDate, @EndDate) AS NewDate

Return Value = 0 Year


SELECT DATEDIFF(quarter, @StartDate, @EndDate) AS NewDate
Return Value = 1 quarter


SELECT DATEDIFF(Month, @StartDate, @EndDate) AS NewDate
Return Value = 2 Month


SELECT DATEDIFF(dayofyear,@StartDate, @EndDate) AS NewDate
Return Value = 61 day


SELECT DATEDIFF(Day, @StartDate, @EndDate) AS NewDate
Return Value = 61 Day


SELECT DATEDIFF(Week, @StartDate, @EndDate) AS NewDate
Return Value = 9 Week


SELECT DATEDIFF(Hour, @StartDate, @EndDate) AS NewDate
Return Value = 1464 Hour


SELECT DATEDIFF(minute, @StartDate, @EndDate) AS NewDate
Return Value = 87840 minute


SELECT DATEDIFF(second, @StartDate, @EndDate) AS NewDate
Return Value = 5270400 second


DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate ='2007-06-05'
SET @EndDate ='2007-06-06'

SELECT DATEDIFF(millisecond, @StartDate, @EndDate) AS NewDate

Return Value = 86400000 millisecond

SQL DATEDIFF Function

SqlTutorials

21 comments:

dghnfgj said...

welcome to the wow power leveling cheap wow power leveling service site,WoW Gold buy cheap wow gold,wotlk gold,world of warcraft power leveling buy wow gold

jjddgo said...

aion chinaaion china goldaion cn goldaion chinese goldaion gold chinaaion gold chinesechina aion goldchinese aion goldaion china kinaaion chinese kinaaion kina chinachina aion kinaaion china buybuy aion chinaaion chinese server goldaion cn server goldaion china server goldchina aion server goldchinese aion server goldaion chinese server goldaion cn server kinaaion china server kinachina aion server kinachinese aion server kina

xiang said...

buy wow gold,cheap wow gold,power wow power levelingworld of warcrft gold.cheep wow gold,buy wow goldworld of warcrft gold.

cheap wow gold said...

www.wowgolds.org has the lowest wow gold price in the cheap wow gold market.The store has been dealing with wow gold business for 5 years.Every day thousands of customers come to buy wow gold for its cheaper price.Our store has stored a large number of World of Warcraft Gold. Customers can purchase wow gold of any characters at any time. And we also provide the best services for customers. We can deliver the World of Warcraft Gold in just 30 minutes,and make the whole online transaction of cheap wow gold in only 10 minutes.by edmund chein

dreaz said...

I am grateful to you for this great content.aöf thanks radyo dinle cool hikaye very nice ssk only cinsellik very nice ehliyet only home free kadın last go korku jomax med olsaoy hikaye lesto go müzik dinle free only film izle love aşk only mp3 indir only radyolar lest go açıköğretim free net only filmler

琪琪 said...

If on the other hand, you need a detailed manual, the instructions are there for you to access.
...........................................................
...

琪琪 said...

you are not our mother. She has a soft, pleasant voice, but your voice is rough, you are the wolf.
...................................................
......

琪琪 said...

who has started the last 12 games in the absence of Yi Jianlian. "I know I've improved a ton defensively this season."
...................................................
.......

Ashley said...

WoW nice blog buddy!Actually WoW is my favorite appreciation keyword. I also like to play. Wow Gold. I was looking for info regarding that and saw your website. Its nice and very interesting.

ravi said...

Good Job....

nanchang said...

Your blog is very good, it's the best blog I've ever seen, thank you!
By the way, do you like polo shirts, which are very chic, especially the polo t shirts, I love them very much. I also like playing tennis rackets, it can keep healthy, what do you like to do? I'd like to introduce myself as the outlet of polo t shirts women, polo t shirts on sale, and polo t shirts for women. These products are our masterpieces, such as polo shirts on sale, polo shirts men, men's polo shirt, men polo shirt, mens polo shirts, mens polo shirt, besides we also sell cheap polo shirts, discount polo shirts, men's polo shirts, women's polo shirts. We are also the outlet of, cheap tennis racket, discount tennis racket, we recommend prince tennis racquet, head tennis rackets, wilson tennis racket, babolat tennis racquet. And it is our great pleasure that you come to our store online!

Mind said...

wow news

Nice posting

Mind said...

wow gold kaufen


Interesting post

admin said...

Is there any chance that running the command in previous versions of SQL Server that guns are running on the latest version?

Best Regards
http://sqltutorial.info

admin said...

Is there any chance that running the command in previous versions of SQL Server that guns are running on the latest version?

Best Regards
SQL Tutorial

GuildWars2Items said...

The past is gone and static. Nothing we can do will change it.scarlet blade gold, the future is before us and dynamic. Everything we do will affect it rs gold, You laugh at mescarlet blade gold for being different , but I laugh at you for being the same.

GuildWars2Items said...

Empty what's full. Scratch where it itches. Don't go around saying the world owes you a living rs gold, The world owes you nothing. It was here first. Being happy doesn't mean that everything is perfect Runescape Gold, It means that you've decided to look beyond the imperfections. Do not pray for tasks equal to your powersrs gold.

fgdg said...

The bravery of each bull is then rated with care according to the number of times he demonstrates his willingness to charge in spite of the sting of the blade Runescape gp, Henceforth will I recognize that each day I am tested by life in like manner. If I persist, if I continue to try, if I continue to charge forward, I will succeed rs gp, Your future depends on your dreams Runescape2 Gold. So go to sleep. Do not keep anything for a special occasion..

fgdg said...

The past is gone and static. Nothing we can do will change it.scarlet blade gold, the future is before us and dynamic. Everything we do will affect it rs gold, You laugh at mescarlet blade gold for being different , but I laugh at you for being the same.

fgdg said...

The bravery of each bull is then rated with care according to the number of times he demonstrates his willingness to charge in spite of the sting of the blade Runescape gp, Henceforth will I recognize that each day I am tested by life in like manner. If I persist, if I continue to try, if I continue to charge forward, I will succeed rs gp, Your future depends on your dreams Runescape2 Gold. So go to sleep. Do not keep anything for a special occasion..

حسام داود said...

levelشركة تسليك مجارى بالرياض
شركة تنظيف بالرياض
شركة تنظيف شقق بالرياض
شركة تنظيف منازل بالرياض
شركة تنظيف خزنات بالرياض
شركة مكافحة حشرات بالرياض
شركة رش مبيدات بالرياض
شركة تخزين اثاث بالرياض
شركة تنظيف مجالس بالرياض
شركة تنظيف فلل بالرياض