About 36,500 results
Open links in new tab
  1. SQL DATEPART(dw,date) need monday = 1 and sunday = 7

    Jul 22, 2014 · DATEPART(dw,ads.date) as weekday I need the result so: Sunday = 7 Monday = 1 etc. Is there any shortcut to do this? Or I will have to do a CASE statement?

  2. Extracting hours from a DateTime (SQL Server 2005)

    May 28, 2017 · Or you could save a few lines with a modulus: DATEPART (HOUR, R.date_schedule) % 12 , and simpler case statements to handle the 0s (which should return …

  3. sql - Extracting hour value from datetime column using DATEPART ...

    I'm trying to extract the numerical hour value from a column that contains time formatted as DateTime. For example, here are a couple of records from that column: Time Aired 4:20:00 …

  4. Get day of week in SQL Server 2005/2008 - Stack Overflow

    5 You can use DATEPART(dw, GETDATE()) but be aware that the result will rely on SQL server setting @@DATEFIRST value which is the first day of week setting (In Europe default value 7 …

  5. sql server Get the FULL month name from a date - Stack Overflow

    Apr 1, 2009 · How do I use sql to get the whole month name in sql server? I did't find a way using DATEPART(mm, mydate) or CONVERT(VARCHAR(12), CreatedFor, 107). Basically I need in …

  6. How to return only the Date from a SQL Server DateTime datatype

    Sep 22, 2008 · If I can get on my soapbox for a second, this kind of formatting doesn't belong in the data tier, and that's why it wasn't possible without silly high-overhead 'tricks' until SQL …

  7. SQL Server DATEPART for year and month - Stack Overflow

    Jun 19, 2015 · I have a call in SQL Server 2012 that I need to have working on Server 2005 and 2008. FORMAT(Date, 'yyyyMM') = 201501 is what I am currently using and need to use …

  8. Get week day name from a given month, day and year individually …

    SELECT DATENAME(dw,'09/23/2013') as theDayName this SQL query returns: 'Monday' This is all OK. But I would like to pass Month, Day and Year individually. I am using the builtin …

  9. sql server - Get week number in year from date - Stack Overflow

    select datepart (iso_week, '2023-03-22') Because in a SQL view you cannot set datefirst which is a session variable. I found the right documentation: ISO Week Number You can also return …

  10. sql - Get 2 Digit Number For The Month - Stack Overflow

    Feb 20, 2013 · I have an integer column "Month" I would like to get 2 digit number for month. This is what I have tried: DATEPART(mm, @Date) It returns one digit for months January to …