Friday, February 24, 2012

Date difference in month

Hi

How can I show the date difference from a previous day till today in month. I need output like this -

Date Month

2007-01-01 3

2007-02-01 2

Thnx

Kapalic

Try:

SELECT DATEDIFF(m,'2007-01-01',GETDATE())

You'll get the amount off months from 1-1-2007 till now.

|||take not that datediff(month, returns the different in month as a whole even if the day different is 1 day.

Try this
select datediff(month, '2007-01-31', '2007-02-01')

No comments:

Post a Comment