Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 31st, 2007, 01:12 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
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.
Reply With Quote
  #2 (permalink)  
Old April 2nd, 2007, 02:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #3 (permalink)  
Old April 3rd, 2007, 09:20 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,190
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
================================================== =========
Reply With Quote
  #4 (permalink)  
Old April 3rd, 2007, 11:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 04: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 01:42 AM



All times are GMT -4. The time now is 05:10 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.