Viewing 15 posts - 2,206 through 2,220 (of 3,008 total)
This does the same as my last post. It just has the functions calls for SundaysInMonth nested.
select
[Year]= year(a.DT),
[Month] = month(a.DT),
SundaysInMonth =
(datediff(dd,
dateadd(dd,((datediff(dd,-53684,dateadd(mm,datediff(mm,0,a.DT),0)+6)/7)*7),-53684),
dateadd(dd,((datediff(dd,-53684,dateadd(mm,datediff(mm,-1,a.DT),-1))/7)*7),-53684)
)/7)+1
from
( -- Test dates, all months for 2008
select...
September 3, 2008 at 1:43 pm
This shows a different method that only requires a single select statement.
select
[Year]= year(FirstSunday),
[Month] = month(FirstSunday),
SundaysInMonth = (datediff(dd,FirstSunday,LastSunday)/7)+1
from
(
select
*,
FirstSunday =
-- First Sunday of the Month
dateadd(dd,((datediff(dd,-53684,aa.Day7)/7)*7),-53684),
LastSunday =
-- Last Sunday of the Month
dateadd(dd,((datediff(dd,-53684,aa.EOM)/7)*7),-53684)
from
(
select
Day7...
September 3, 2008 at 1:34 pm
Paul Manning (9/3/2008)
Thanks Michael Valentine Jones, I can't say I understand it but that worked perfectly!! 😀
The basic algorithm is to find the difference in days from the earliest...
September 3, 2008 at 12:55 pm
Make sure the tables you are looking at have a clustered index. If there is no clustered index, the table is a heap, and the data itself cannot be...
September 2, 2008 at 7:56 pm
manish.jain (9/1/2008)
Hi,Thanks for your reply,
At this stag i am dumb... i am looking for some other good solution.
Would you please suggest me any other good way?
Thanks
Manish Jain
When you tried...
September 2, 2008 at 7:46 pm
The way you have your query written, you will miss any rows that fall in the last second of the day.
When you query for a date range, it is better...
September 2, 2008 at 7:38 pm
You can use the function on this link for what you want to do.
Date Table Function F_TABLE_DATE
September 2, 2008 at 3:52 pm
ss1011 (9/2/2008)
...This is why we recommend cold backups. We also recommend a scheduler to start/stop our default instance. But I suppose I can look into an...
September 2, 2008 at 11:40 am
This should do what you want
select
Weekending =
-- Find end of week date for week Sun-Sat
dateadd(dd,((datediff(dd,-53684,a.salesdate)/7)*7)+6,-53684) ,
a.line,
sum(a.cost)
from
#DAILY a
group by
dateadd(dd,((datediff(dd,-53684,a.salesdate)/7)*7)+6,-53684) ,
a.line
order by
dateadd(dd,((datediff(dd,-53684,a.salesdate)/7)*7)+6,-53684) ,
a.line
September 2, 2008 at 9:18 am
DBCC INDEXDEFRAG stored procedure
http://weblogs.sqlteam.com/tarad/archive/2004/07/30/1834.aspx
August 25, 2008 at 12:43 pm
You need to look at the type of paging to know if there is a problem.
Running backups can cause paging as the OS allocates file system cache, and this is...
August 25, 2008 at 10:01 am
There is also another side to this: toleration of people that cheat. People that would never cheat themselves are often willing to overlook it in others. Is an...
August 25, 2008 at 9:40 am
Sadly, I am not longer shocked by this level of incompetence by a vendor. Actually, I have come to expect it.
Another big problem to watch is a mismatch between...
August 22, 2008 at 6:41 pm
dmc (8/22/2008)
HA! Short indeed.. but the post asked for a character based result. But koodos if the string data type is not really needed.
You do realize that the...
August 22, 2008 at 6:26 pm
Viewing 15 posts - 2,206 through 2,220 (of 3,008 total)