1. Registered User
Join Date
Jan 2002
Location
Berlin
Posts
72

Hi,

I am simply looking for a calculation to get back always the last day of the month. Can anybody help me ?

2. The SQL Apostle
Join Date
Jul 2003
Location
The Dark Planet
Posts
1,401

## Re: Date calculation

Originally posted by dajm
Hi,

I am simply looking for a calculation to get back always the last day of the month. Can anybody help me ?
Code:
```declare @month int,
@year int
select @month = 2,
@year = 2000
I assume you must be passing the year & month to get the last day of the month. The above will work for that

3. Window Washer
Join Date
Nov 2002
Location
Jersey
Posts
10,322

Code:
```DECLARE @x datetime
SELECT @x = GetDate()
What happens with this?

Code:
```declare @month int,
@year int
select @month = 12,
@year = 2000
???????

4. The SQL Apostle
Join Date
Jul 2003
Location
The Dark Planet
Posts
1,401
Good point brett !!!

5. The SQL Apostle
Join Date
Jul 2003
Location
The Dark Planet
Posts
1,401
I dont seem to unserstand .. why all my posts are being posted in the duplicate today ???? i mean for every post i am making ... its being submitted twice
Last edited by Enigma; 12-01-03 at 16:33.

6. Registered User
Join Date
Jan 2002
Location
Berlin
Posts
72
Originally posted by Brett Kaiser

Code:
```DECLARE @x datetime
SELECT @x = GetDate()
What happens with this?

Code:
```declare @month int,
@year int
select @month = 12,
@year = 2000
???????
Sorry Brett, your function gives me back the same day of the last month. I am searching for something following: today is 2003/12/02 and what I need the get returned is 2003/11/30. How about this ? Any chance ?

7. Registered User
Join Date
Jan 2002
Location
Berlin
Posts
72
Sorry guys,

I am really dump !!!

All i needed is the following:

select getdate()-(datepart(dd,getdate() )

8. The SQL Apostle
Join Date
Jul 2003
Location
The Dark Planet
Posts
1,401
Originally posted by dajm
select getdate()-(datepart(dd,getdate() )
Brilliant !!!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•