473,322 Members | 1,496 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,322 software developers and data experts.

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 5332
"bad" <d.***********@mervisoft.de> wrote in message
news:3F***************@mervisoft.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=$week*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==$weekstart) $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***************@mervisoft.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',$soytime); // 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("+$weekoffset week",$soydatetime); // 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",$soweektime)); // 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*********@willglen.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
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...
1
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...
2
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...
1
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? ...
2
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...
21
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...
5
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,...
14
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
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.