Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How many days the function dateadd add in a month?

Author  Topic 

rsegecin
Yak Posting Veteran

82 Posts

Posted - 2007-09-29 : 06:10:26
How many days the function dateadd add for an month? 30, 31, 28?

thank you.

Ideas are bullet proof.

Vendetta.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-09-29 : 06:16:04
It is not really adding days. But 1 month.
see this

SELECT	[date], [date + 1 MONTH] = DATEADD(MONTH, 1, [date])
FROM
(
SELECT [date] = '2007-01-01' UNION ALL
SELECT [date] = '2007-01-31' UNION ALL
SELECT [date] = '2007-03-31' UNION ALL
SELECT [date] = '2007-04-30'
) d
/*
date date + 1 MONTH
---------- ------------------------------------------------------
2007-01-01 2007-02-01 00:00:00.000
2007-01-31 2007-02-28 00:00:00.000
2007-03-31 2007-04-30 00:00:00.000
2007-04-30 2007-05-30 00:00:00.000
*/



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

rsegecin
Yak Posting Veteran

82 Posts

Posted - 2007-09-29 : 08:12:27
Ok thank you khtan for clear it up in my mind. =D

Ideas are bullet proof.

Vendetta.
Go to Top of Page
   

- Advertisement -