Re: calculate the midle and end of the month
From: Steve Kass (skass_at_drew.edu)
Date: 01/08/05
- Next message: John Kane: "Re: FullTextIndex"
- Previous message: Steve Kass: "Re: SQL Server 2000 BUG?"
- In reply to: Gonzalo Torres: "calculate the midle and end of the month"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 07 Jan 2005 21:08:36 -0500
Gonzalo,
Another way to get the 15th and last dates of the month:
declare @m datetime
set @m = '20040221 14:23:11' -- to identify the month you want
select
dateadd(month, datediff(month, '19000101', @m), '19000115') as midMonth,
dateadd(month, datediff(month, '19000101', @m), '19000131') as endMonth
Steve Kass
Drew University
Gonzalo Torres wrote:
>Hi
>I have a table with a datetime field that I use to get a date of process for
>my application.
>I have stored the dates:
> 15/01/04
>
> 31/01/04
>
> 15/02/04
>
> 29/02/04
>
> 15/03/04
>
> 31/03/04
>
> 15/04/04
>
>
> .
> .
> .
>and so on...
>This means I write the every 15th day of a month and every end of a month.
>As it's shown, 2004 it's a leap year, that's
>why the 29/02/04. But I have to check if the actual year is a leap year or
>not, so I type 29/02/04 or 28/02/04.
>As I have to type all these dates, is there a way to get them automatically?
>Let's say, the dates of 2005?
>
>
>
>
- Next message: John Kane: "Re: FullTextIndex"
- Previous message: Steve Kass: "Re: SQL Server 2000 BUG?"
- In reply to: Gonzalo Torres: "calculate the midle and end of the month"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|