About 594,000 results
Open links in new tab
  1. sql server - Get the last day of the month in SQL - Stack Overflow

    I need to get the last day of the month given as a date in SQL. If I have the first day of the month, I can do something like this: DATEADD (DAY, DATEADD (MONTH,'2009-05-01',1), -1) But does anyone ...

  2. Get the records of last month in SQL server - Stack Overflow

    Sep 15, 2009 · Using YEAR (), MONTH (), DATEPART () or similar functions on the date being filtered eliminates any possibility that SQL server can optimize the query to use an index on that date.

  3. sql server - sql - beginning of hour, month etc - Stack Overflow

    select dateadd(DAY, datediff(day, 0, getdate()),0) (result:2009-09-17 00:00:00.000) I need to get (in SQL) the current date with the beginning of this hour. For example: 2009-09-17 17:00:00 (I don't care …

  4. sql server - How do I calculate the last day of the month in SQL ...

    Oct 8, 2008 · SELECT DATEADD(M, @calc, '1990-01-31T00:00:00.000') This adds @calc month granules to the last day of the reference month, the result of which is the current timestamp 'rounded' …

  5. sql server - How can I select the first day of a month in SQL? - Stack ...

    How can I determine if the noted cardinality estimation bug will affect me? It is marked as fixed in 2010. Does that mean that only SQL Server 2012 and newer are safe, or is it possible that a 2008 server …

  6. Getting only Month and Year from SQL DATE - Stack Overflow

    Nov 23, 2009 · SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, <dateField>), 0) AS [year_month_date_field] FROM <your_table> This gets the number of whole months from a base …

  7. Get first Sunday of next month using T-SQL - Stack Overflow

    Oct 2, 2009 · Looking for a way to get the date in the format "11/1/2009", which would be the first sunday of next month. I want to run this query after the first sunday in october to get the first sunday …

  8. SQL Server: Get data for only the past year - Stack Overflow

    Aug 27, 2007 · There's variants with DATEDIFF and DATEADD to get you midnight of today, but they tend to be rather obtuse (though slightly better on performance - not that you'd notice compared to …

  9. t sql - SQL Count for each date - Stack Overflow

    I used this but the created_date is a field with a full datetime so I had to apply this little hack: DATEADD (dd, 0, DATEDIFF (dd, 0, created_date)) in the group by part and it all worked like a charm!! :)

  10. sql - Calculate the last day of the prior quarter - Stack Overflow

    Sep 30, 2008 · What's the most efficient way to calculate the last day of the prior quarter? Example: given the date 11/19/2008, I want to return 9/30/2008. Platform is SQL Server