Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Group By Having Problems
Message
 
 
To
22/03/2005 10:52:28
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00998084
Message ID:
00998122
Views:
17
>Thanks for posting that Sergery, I was actually trying to find out how to do that the other week. :)

You're welcome. You can also use the same technique to calculate begining of other periods by substituting 'day' part with other part. For example,
DECLARE @dt datetime
SET @dt = GETDATE()

-- begining of the month date
SELECT DATEADD(mm, DATEDIFF(mm, 0, @dt), 0)
-- begining of the year date
SELECT DATEADD(year, DATEDIFF(year, 0, @dt), 0)
-- e.t.c
BTW, this and some other tips and tricks has been published in 2004 issues of UT magazine.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform