![]() ![]() ![]() once you have the and set, the following calculates the date range. SELECT = DATEPART(WK, = CAST(DATEPART(YY, AS CHAR(4)) Set = GetDate() - set date to current Date for testing Week () function in sql script Ask Question Asked 14 years, 6 months ago Modified 6 years ago Viewed 15k times 2 I am using sql server 2005. DECLARE datetime - For testing Select statements RETURNS TABLE (StartOfWeek DateTime, EndOfWeek DateTime) IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'.') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))ĭROP FUNCTION. List of all available formats DD, 01-31, The day of the month, 2-digits d, 0-6, The day of the week, with Sunday as 0 dd, Su-Sa, The min name of the day of. "The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom RE: Converting week number to actual date pandatime (Programmer) So, the same way I need to know the week number of a given (variable) date. Like : say Date '' belongs to the 1st week of the year 2008, same way '' is 8th week of the year 2008. The number-of-the-week value is represented as a decimal number in the range 053, with a leading zero and maximum value of 53. ** Note: I really don't eat that many pizzas. Can anybody tell me to How to get the week number of a specific Date in SQL Server 2005. Select DateAdd(Day, -DateDiff(Day, -1, CreateDate) %7, CreateDate) As StartOfWeek,įrom BY DateAdd(Day, -DateDiff(Day, -1, CreateDate) %7, CreateDate)Īs you can see, the data is broken out by week with the first day of the week shown in the output. Declare Table(CreateDate DateTime, PizzasEaten Int)
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |