TSQL Function

Get help on databases - MySQL, Oracle, Access, etc.
Post Reply
v1c
Registered User
Posts: 313
Joined: 22 Jun 2002, 02:00
Contact:

TSQL Function

Post by v1c »

Hi Guys

Anyone know of a TSQL function to grab the number of days in a month, or will I have to calculate it myself?

Thanks
viceroy
Registered User
Posts: 3565
Joined: 27 Mar 2006, 02:00
Location: I forget

Post by viceroy »

will you just be inputing a month name, or number or can you input a date and need the max days for the month?
Image
v1c
Registered User
Posts: 313
Joined: 22 Jun 2002, 02:00
Contact:

Post by v1c »

I've got the following...

SELECT DAY(DATEADD (m, 1, DATEADD (d, 1 - DAY(GETDATE()), GETDATE())) - 1) as NumDays

Lets hope it works.
viceroy
Registered User
Posts: 3565
Joined: 27 Mar 2006, 02:00
Location: I forget

Post by viceroy »

Yeah, thats about the simplest way of getting it
Image
Post Reply