| Login

Search this Blog

Here are the most recent postings to this blog. Use the archive calendar or search to find other entries.
Jul3

Written by:R Teachout
7/3/2008 1:30 AM 

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

 

The logic behind this 'last day of the month' calculation is that you get the month part of a given date, add one to it to get to the next month. Then subtract 1 day from the first of that month.

This can be written in one line and here it is:

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

Tags:

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment  Cancel 


-quoteworld.org

Inspired by Nina