473,778 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

year week

bad
i´ve two variables the year and the week (2003 and 5) that means the 5th
week of the year 2003.
now i need the start- and enddate of the 5th week of year 2003.

i hope someone can help me to solve this problem.

Jul 17 '05 #1
3 5355
"bad" <d.***********@ mervisoft.de> wrote in message
news:3F******** *******@merviso ft.de...
i´ve two variables the year and the week (2003 and 5) that means the 5th
week of the year 2003.
now i need the start- and enddate of the 5th week of year 2003.

i hope someone can help me to solve this problem.

You don't need the year to work this out as it will be the same for every
year.

$weekstart=$wee k*7;
$weekend=$week* 7+7;

for $a=1; $a<=365; $a++) {
if($a>1 AND $a<=31) $month="Jan";
if($a>31 AND $a<=59) $month="Feb";
etc. etc. until Dec.
if($a==$weeksta rt) $startdate="$a $month";
if($a==$weekend ) $enddate="$a $month";
}
Untested of course, but should crudely do the trick.
Richard Grove

http://shopbuilder.org - ecommerce systems
Become a Shop Builder re-seller:
http://www.affiliatewindow.com/affil...ls.php?mid=611
http://www.affiliatewindow.com/a.pl?590
Jul 17 '05 #2
Richard Grove wrote:
"bad" <d.***********@ mervisoft.de> wrote in message
news:3F******** *******@merviso ft.de...
i´ve two variables the year and the week (2003 and 5) that means the
5th week of the year 2003.
now i need the start- and enddate of the 5th week of year 2003.


You don't need the year to work this out as it will be the same for
every year.


The start- and enddate depends on the year, so your code won't work - no
matter what it does.
Jul 17 '05 #3

On 3-Nov-2003, bad <d.***********@ mervisoft.de> wrote:
i´ve two variables the year and the week (2003 and 5) that means the 5th
week of the year 2003.
now i need the start- and enddate of the 5th week of year 2003.

i hope someone can help me to solve this problem.


$year = 2003;
$week = 4;

// this assumes that the first week of the year starts on a Sunday
$weekoffset = $week-1; // make week offset zero based
$soytime = strtotime("1/1/$year"); // get the timestamp for the 1st day of
the year
$soyoffset = date('w',$soyti me); // get the number of days past sunday
$soydatetime = strtotime("-$soyoffset day",$soytime) ; // get the timestamp
for the sunday before or == to the start date of the year
$soweektime = strtotime("+$we ekoffset week",$soydatet ime); // get the
timestamp for the sunday of the week

$startOfWeek = date('m/d/Y',$soweektime) ; // convert the timestamp to a date
$endOfWeek = date('m/d/Y',strtotime("+ 1 week",$soweekti me)); // add a week
and convert to a date

--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@wil lglen.net (it's reserved for spammers)
Jul 17 '05 #4

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

Similar topics

21
1925
by: .:mmac:. | last post by:
I have to update a page every week. I get the page ahead of time so I used the "scheduled includes" webbot in Frontpage only to find that I would have to refresh the page every week to have it work. That is silly, it should run by itself. so... I asked the question in the FP group and I was offered this pseudocode to do it by month which would work if it's possible to do it by week without writing 52 seperate lines, one for each week which...
1
2502
by: MissiMaths | last post by:
This isn't really an access question as I can write the code myself(I hope) but need to know how the start of the financial year is worked out. If someone knows the rules or an algorithm, I would be most grateful. In 2001, when the 1st April 2004 was on a sunday, the first (monday to friday) week of the financial year was the 9th to 13th April. In 2002, the 1st was on a monday and the first week was 8th to 12th april. In 2003, the 1st...
2
1089
by: | last post by:
Hi!! know someone how to get a week span with week number and year? something like hi: public static DateTime GetWeekSpan(int weekNumber, int year) { DateTime weekStartDate = new DateTime(); DateTime weekEndDate = new DateTime();
1
2889
by: Martin Emanuelsson | last post by:
Hello, Knowing year and weeknumber of this year, I'm looking for some way to get the date of the first and last day of that particular week. Does anyone have an idea about how to do this? Best regards Martin
2
3860
by: Benz | last post by:
Hello all, Can anyone please tell me how to find the first and last date of a week when the year and the week number is given? The week model followed is the ISO model: Monday is the 1st day of the week and the 1st week should have atleast 4 days. I got to see one thread on this topic, but it doesnt work.. there are problems with it when an year has 52 or 53 weeks in it....
21
3188
Jezternz
by: Jezternz | last post by:
Okay. Simple as it sounds, but possibly complex. I have $week (which is the week in a year 1-52) and I have $year. I want to get the day of the saturday in the given $week and $year, so i want returned: $day (being day of month, will be the saturday of he origonal given week), $month (the month 0-12) and $year. Bit of a brain tease for me atleast. Any Idea's?
5
6084
by: Aljosa Mohorovic | last post by:
i use this to find out current week and total number of weeks for current year: now = datetime.now() weeks_in_year = int(date(now.year, 12, 31).strftime("%W")) current_week = int(date(now.year, now.month, now.day).strftime("%W")) is this the best way or is there a better way? Aljosa Mohorovic
14
19073
by: Tommy Jakobsen | last post by:
Hi. Is there a method in .NET that takes "year" as an argument and returns the total number of weeks in that year? For culture da-DK (Danish). Thanks in advance. Tommy.
3
5840
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, is there a way if you are given a Year and a Week an easy way to go back say 26 weeks ago from given year/week. for example, given: 2008/16 26 weeks prior is: 2007/43 thanks,
0
9629
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9470
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10127
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10069
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8957
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3627
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2865
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.