473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How would I get the dates from the previous wednesday to the last tuesday?

rf
Hey I need to be able to get the dates from last wednesday to the past
tuesday on thursday or friday every week. How would I do that?

For example:
m t W TH F
M T w th f

I would need the dates of the CAPITAL W and T when I run the script
from the last th or f

So if today is 2006-1-19 I would need 2006-1-11 and 2006-1-17

Thanks for the help.

Jan 17 '06 #1
2 2912
"rf" <ry***@twcny.rr.com> kirjoitti
viestissä:11**********************@o13g2000cwo.goo glegroups.com...
Hey I need to be able to get the dates from last wednesday to the past
tuesday on thursday or friday every week. How would I do that?

For example:
m t W TH F
M T w th f

I would need the dates of the CAPITAL W and T when I run the script
from the last th or f

So if today is 2006-1-19 I would need 2006-1-11 and 2006-1-17

As usually, there's more than one way to do it, here's one:
First find out what was last tuesday, easy as pie with strtotime:

$last_tuesday = strtotime('last tuesday');

After that you can get all the dates with the same method (using
$last_tuesday as a reference point instead of today so we don't get this
weeks "last wednesday" if it happens to be friday, but "last wednesday"
counting from last tuesday).

$last_monday = strtotime('last monday', $last_tuesday);
$last_friday = strtotime('last friday', $last_tuesday);
$last_thursday = strtotime('last thursday', $last_tuesday);
$last_wednesday = strtotime('last wednesday', $last_tuesday);

Now you can convert them to human readable formats using date:
echo date('Y-m-d', $last_monday); // for example

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine <an*******************@gmail.com.NOSPAM.invalid>
Jan 17 '06 #2
rf
thanks I never knew about strtotime. Its a very cool function. Thanks
for pointing it out to me.

Jan 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Frank | last post by:
For my website i would like to display the age of my son in years, months, days and hours. For now i manage to get a result for totals. Like the total number of days. This is the beginning: ...
8
by: netsurfer | last post by:
Hi: Have a question on making the date automatically filled in by what the user enters in by the date at the top. The date entered at the top would most likely be on a Wednesday then I need...
3
by: David | last post by:
I'm new to DB2 and I need to write a query that will allow me to find specific dates instead of me having a date range asked for, I want it to be calculated. I've done this in Access by coding...
3
by: SJH | last post by:
I currently have reports (mostly graphs) that utilize dates entered into a form. The dates are pretty baisc from the standpoint of the start and end of the current fiscal year, the start and end...
5
by: Mark Hall | last post by:
Our reporting cycle goes from Wednesday to Wednesday an I need to calculate the next Wednesday after the update was received. If an upate comes in on say a Tuesday (eg 20 Jan 04) then I want a...
2
by: Cillies | last post by:
Hi, I have created a simple update query, that updates the date everyday. i.e. any date before today's date will be updated to todays date. I have it running on an autoexec. macro But I want...
2
by: planetthoughtful | last post by:
Hi All, I'm building some reports in Acc97 and using a custom calendar form to allow users to pick dates with which to report. I'm wondering if there's an easy way in code to be able to...
2
by: MLH | last post by:
With a table of holidays and A97's date fn's - how best to count weekends and holidays between two dates? My holiday table has 4 fields. I will be adding records to it each year as info becomes...
1
by: Pradeepa01 | last post by:
Hi, We are facing an issue with the JDBC query, I need help on. I have 3 fields, UPC_ID, QTY,Date I have to retrieve all the records for one UPC_ID whose QTY is same for last five days. The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.