Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2006, 04:33 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default Counting Fridays in a Quarter

Hi All,

I've searched the archives here and haven't been able to find anything on this topic.

I need to be able to count the number of Friday's in a quarter. And how to count the number of Fridays left in a quarter. I have to create work orders for scheduling jobs. These work orders will be assigned to the Fridays in each quarter.

Your response is greatly appreciated. Thank you.

Richard

 
Old April 24th, 2006, 12:00 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

OK... I'm making some sort of progress here.

I can find the first Friday of the year.

Code:
SELECT DateAdd(wk, DateDiff(wk, 0, DateAdd(yy, DateDiff(yy, 0, GetDate()), 0)), 4);
Next I'll be working to get the first Friday of the Quarter.

Thanks for any suggestions.

Richard

 
Old April 24th, 2006, 03:10 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

OK... I figured it out.

I created a Fridays table. Used this script in Classic ASP to enter in 10 years of Fridays.

Code:
    theCounter = 0
    Do until theCounter >= 3640
    SQL2 = "select dateadd(dd, (datepart(dw, '1/1/2006') * -1) + 6, '1/1/2006') + "& theCounter & " AS 'TheDate';"
    Set oRS2 = oConn.Execute(SQL2)
    thefriday = FormatDateTime(oRS2(0),2)
    SQL3 = "INSERT INTO Fridays (FridayDate,Status) Values ('"&thefriday&"', 1);"
    oConn.Execute(SQL3)
    theCounter = theCounter + 7
    Loop



Now all I have to do is use BETWEEN to find any info on Fridays that I might need.

Hope someone else can use this too.

Richard







Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting pixels shanthi85 VB How-To 0 May 22nd, 2007 02:13 AM
charachter counting bjackman Access 12 March 11th, 2005 04:51 AM
Click Counting mani_he Pro PHP 5 December 25th, 2004 01:33 PM
return record count by quarter jtyson SQL Server 2000 1 June 29th, 2004 11:24 PM
Counting ?!? hcweb Classic ASP Basics 2 December 8th, 2003 05:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.