Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language 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 March 31st, 2007, 12:12 AM
Registered User
 
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic Date Display

Hi all. I'm very new at sql so first I hope I'm posting in the right place. I'm using ms access until I hone my skills so here goes:

Each week a different member of my website contributes to our mp3 collection. I have a schedule that I made in javascript but I need to manually change it every week. What I would like to do is populate an access table with every Sunday date from now to 2008 and then create a query that will use the current date() and display who's week it is.
Is this possible?

I'm grappling with the DateAdd and DateDiff functions but I'm not a good enough programmer or I don't think programmatically enough to work out how to do this.

What I have now is:
Code:
SELECT tblRotaion.RotationWeek, tblRotaion.Member
FROM tblRotaion
WHERE (((tblRotaion.RotationWeek)<=Date()));
Which returns:

Code:
RotationWeek    Member

3/25/2007    Many
3/18/2007    Moe
3/11/2007    Jack
All I want to return however is the most recent Sunday not all Sundays in the past. Then next week, 4/1/07 will be a new person.

Thanks in advance.
 
Old April 2nd, 2007, 01:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Not sure if I understood that right. What is that you wanted to accomplish. Can you explain please?

_________________________
- Vijay G
Strive for Perfection
 
Old April 3rd, 2007, 08:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

little idea:

Code:
SELECT TOP 1 tblRotaion.RotationWeek, tblRotaion.Member
FROM tblRotaion
WHERE tblRotaion.RotationWeek<=Date()
ORDER BY tblRotaion.RotationWeek DESC;
that will return only 1 row...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
 
Old April 3rd, 2007, 10:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

You need to use the combination of DateAdd and DatePart funtions. Assuming your Week starts from Sunday, using Datepart find which day of the week you execute this statement, and reduce this number from current date to get to sunday's date. Thus you can query directly for EQUAL to recent Sunday's date. Somthing like this...
Code:
SELECT tblRotaion.RotationWeek, tblRotaion.Member
FROM tblRotaion
WHERE tblRotaion.RotationWeek = DateAdd(d, -DatePart(dw, Date()), Date())
Not sure how well the date functions are supported in MSAccess.

Hope that helps.
Cheers

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic display using logic tags rajesh_css Struts 1 December 23rd, 2008 03:42 AM
ASP vbscript dynamic image display johneecc Classic ASP Professional 10 January 31st, 2008 01:34 PM
Dynamic Form Display Morn ASP.NET 2.0 Basics 0 March 13th, 2007 03:30 PM
Dynamic Display Problem gabster XSLT 2 March 5th, 2007 03:02 PM
How to dynamic display the content of the table? myhrvod Pro Java 0 August 3rd, 2006 12:42 AM





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