473,563 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2928
"rf" <ry***@twcny.rr .com> kirjoitti
viestissä:11*** *************** ****@o13g2000cw o.googlegroups. 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.ber keley.edu/>
Kimmo Laine <an************ *******@gmail.c om.NOSPAM.inval id>
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
4380
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: starttime = Date.parse("Aug 10,2003, 07:07") sdt = new Date(starttime)
8
2223
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 to have all the prior dates pop in. Example: User enters 2/9/05 in the date field at the top being a Wednesday...I need the dates at the bottom to...
3
13488
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 visual basic scripts and making monthly reporting automatic. No longer having to change 15 queries to match specific date ranges for the previous...
3
2451
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 of last fiscal year, previous month start and end dates, etc. My users would like to enter one set of dates (preferably the previous month start...
5
645
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 field on the form to show Wednesdays date (eg 21 Jan 04). However, if the update comes in on Thursday (eg 22 Jan 04) then the field would be...
2
1555
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 to be able to update it every 7 days, but at the same time take into consideration the weekends. I just want to use the 5 working days of the week...
2
2338
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 automatically work out the end-of-week date and end-of-month date from an arbitrary date value? To explain a little further. Let's say a user wants to...
2
3132
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 known. What approach would you advise to tally up the number of holidays, saturdays and sundays between any 2 dates in the range of my records in...
1
3856
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 problem here is the QTY will not be inserted on sundays. When when we run the query on a Monday, we should consider the Qty for last wednesday to saturday...
0
7664
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.