Viewing 15 posts - 346 through 360 (of 443 total)
gerald.drouin (8/12/2009)
declare @DayToFind tinyint, @AnyDayInAMonth datetimeselect @DayToFind = 1, --Monday
@AnyDayInAMonth = '2009-04-15'--Target month
select dateadd(day, (datepart(d, @AnyDayInAMonth) - datepart(dw, @AnyDayInAMonth) - @@datefirst + @DayToFind) % 7, dateadd(day, 1-datepart(d, @AnyDayInAMonth), @AnyDayInAMonth))
Seems like...
August 13, 2009 at 2:10 am
Have a look at this:
http://www.simple-talk.com/sql/sql-server-2005/using-and-monitoring-sql-2005-query-notification/
I tried it some time ago but could never get it to work, you might have more luck.
It all depends whether you can reference...
August 12, 2009 at 9:15 am
publicdh-tech (8/12/2009)
Nigel/Wildh,In my original post (768063), I convert the result to style 101 (mm/dd/yyyy), so it doesn't matter if @dt has a time or not.
David
David,
That is true in...
August 12, 2009 at 8:53 am
wildh (8/12/2009)
August 12, 2009 at 1:57 am
anand.ramanan (8/11/2009)
I think you missed my post on page 1. It has as a similar implementation, and it allows to find the first sunday - saturday of...
August 12, 2009 at 1:54 am
publicdh-tech (8/11/2009)
SET @dt = DATEADD(d,1-DAY(@dt),@dt)
Nigel, nice! Your arithmetic is very crafty and gets a solution in...
August 11, 2009 at 9:59 am
Just worked out an alternative that avoids one of the the modulus operations
SELECT firstsaturday = DATEADD(dd,
...
August 11, 2009 at 9:32 am
No need to change DATEFIRST, create intermediate variables, or a WHILE loop :w00t:.
Just a bit of arithmetic to work out the offset from the first of the month to...
August 11, 2009 at 3:24 am
Jeff Moden (8/5/2009)
Nigel will probably beat me to it, though.
Not a chance, I was sleeping while you were working on this.
Nice solution Jeff, I think I just about get it.
I...
August 6, 2009 at 4:05 am
Jeff Moden (8/5/2009)
Well done Nigel! No temp table, no loops, no cross apply, 100% set based, and can be used in 2k, tk5, or 2k8.
Thank you Jeff....
August 5, 2009 at 9:43 am
aktikt (8/5/2009)
I tried your second solution on 35923 records but I added the
HAVING clause to restrict the rows to 2006 and 2007 with this:
HAVING YEAR(theDay) > 2005 AND YEAR(theDay) <...
August 5, 2009 at 9:39 am
aktikt,
Apologies, just noticed that you don't want it grouped by ClaimID, just the Month and Year.
Try this slightly modified version instead:
SELECT
...
August 5, 2009 at 8:25 am
aktikt,
Try this on your data and let us know how it goes (you will need the Tally table):
SELECT
ID,
...
August 5, 2009 at 8:19 am
First read Jeff Moden's excellent article on Tally tables here[/url]. Create one, then try this:
DECLARE
@startdate datetime,
...
August 4, 2009 at 8:33 am
August 3, 2009 at 7:45 am
Viewing 15 posts - 346 through 360 (of 443 total)