Re: calculate the midle and end of the month

From: Steve Kass (skass_at_drew.edu)
Date: 01/08/05


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?
>
>
>
>



Relevant Pages

  • Re: Dates Result Set
    ... select cast,getdate,112) as datetime) + i as d ... Steve Kass ... Drew University ... tom sawyer wrote: ...
    (microsoft.public.sqlserver.mseq)
  • Re: Get Date from Datetime
    ... Please reply to the newsgroup. ... "Steve Kass" wrote in message ... > SET LANGUAGE French ... > @d is the datetime value you want the date of, ...
    (microsoft.public.sqlserver.programming)
  • Re: How can I Add 02.45 hour to my Date [solution is that best way
    ... How is sql server doing the operation?, It converts the string to datetime ... The conversion of a char data type to a datetime data type resulted in an ... "Steve Kass" wrote: ...
    (microsoft.public.sqlserver.programming)