Murali-220004
SSC Journeyman
Points: 81
More actions
August 19, 2005 at 2:49 am
#88633
Hi to all,
I have some doubts on calculating years, month and days between two days in Single sql query. If any one have solution on this. Please reply.
Thanks
Murali S
ChetShah
SSC Rookie
Points: 43
August 19, 2005 at 3:08 am
#583445
Hi Murali,
There is a script on this site which calculates the Number of Weekdays between two dates - not sure if this is the type of query you're looking for but the link is
http://www.sqlservercentral.com/scripts/contributions/1316.asp
Chet
Chris Hedgate
One Orange Chip
Points: 25041
August 19, 2005 at 3:17 am
#583449
Something like this?
DECLARE @start DATETIME, @end DATETIME
SET @start = '2004-08-01'
SET @end = GETDATE()
SELECT
DATEDIFF(yy, @start, @end) AS years
, DATEDIFF(m, @start, @end) AS months
, DATEDIFF(d, @start, @end) AS days
--Chris Hedgate http://www.hedgate.net/Contributor to the Best of SQL Server Central volumesArticles: http://www.sqlservercentral.com/columnists/chedgate/
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply