Jump to content

Getting info from a database by week...


djanim8

Recommended Posts

I want to get all records from a mySQL database that have a date for this week (starting on Sunday)..

I can get the day of the week (today is Wed...) by doing this: date("w");

so how can I subtract this many days (3) from today's date to get the start? and then add 6 to that date to get the end.. for example:

this is todays date: 08/23/2006

I want to make a dymanic sql statement like this for THIS week (and then whatever week after that).

$mySQL = "SELECT * FROM thistable WHERE thisdate IS BETWEEN ".$firstDate." AND ".$lastDate;

Where first date would be this sunday (08/20/2006) and the last date would be this saturday (08/26/2006)

I can't seem to find code to add and subtract from the current date :(
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.