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
 General SQL Server Forums
 New to SQL Server Programming
 days help

Author  Topic 

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-03-28 : 00:32:56
hi team , i need a function that give list of days of a mint like

select getdays('1-feb-2012')

it returs

1
2
3
4
5
6
7
... till 29

challenge everything

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-03-28 : 02:54:53
[code]
select number
from master..spt_values v
where v.type = 'P'
and v.number >= 1
and v.number <= datepart(day, dateadd(month, datediff(month, 0, '2012-02-01') + 1, -1))
[/code]

use your own number table if you have one


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

Go to Top of Page

pnpsql
Posting Yak Master

246 Posts

Posted - 2012-03-28 : 03:24:08
any more suggestions...

challenge everything
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-03-28 : 03:28:38
what's wrong with that ?

you can use Recursive CTE or while loop if you want


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

Go to Top of Page
   

- Advertisement -