locked
Create a new date RRS feed

  • Question

  • Hi,

    I want to write a query that returns me the first date of the month...

    I wrote this query

    SELECT DateAdd(day,- Day(GetDate()) + 1,GetDate())

    THis works fine for me, is there any function that build a new date, without using the DateAdd function?

    Friday, March 24, 2006 1:14 PM

Answers

  • here is another way

    select dateadd(mm, datediff(mm, 0, getdate())+0, 0)

    and another

    select convert(datetime,(convert(varchar(6),getdate(),112) +  '01'))

    Denis the SQL Menace

    http://sqlservercode.blogspot.com/

    Friday, March 24, 2006 1:23 PM

All replies

  • here is another way

    select dateadd(mm, datediff(mm, 0, getdate())+0, 0)

    and another

    select convert(datetime,(convert(varchar(6),getdate(),112) +  '01'))

    Denis the SQL Menace

    http://sqlservercode.blogspot.com/

    Friday, March 24, 2006 1:23 PM
  • Thanks

    I used the second query :

    select convert(datetime,(convert(varchar(6),getdate(),112) +  '01'))

    Friday, March 24, 2006 2:07 PM