473,320 Members | 2,117 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,320 software developers and data experts.

Calculating week range from specific date - Any functions?

Yes i have the function

First of all calculate the week number of the desired date and apply the following function

function retornarRangoDiasxSemana($anno, $semana)
{
// Determinar el día del inicio del año
$anno = date('Y',mktime(0, 0, 0, 1, 1, $anno));
// 0 para el domingo a 6 para el sábado
$diaInicial = date('w',mktime(0, 0, 0, 1, 1, $anno));
// Establecer los datos iniciales para hacer el cálculo
$finSemana = 7-$diaInicial;
$diaAño = $diaAño+$finSemana;

$diaIni = date('Y/m/d',mktime(0, 0, 0, 1, $diaIni+1, $anno));
$diaFin = date('Y/m/d',mktime(0, 0, 0, 1, $finSemana, $anno));

// Realizar el ciclo hasta la semana deseada
if($semana<54)
{
for($sem=2;$sem<=$semana;$sem++)
{
$diaIni = $diaAño + 1;
$diaFin = $diaIni + 6;
$diaAño = $diaFin;

$diaIni = date('Y/m/d',mktime(0, 0, 0, 1, $diaIni, $anno));
$diaFin = date('Y/m/d',mktime(0, 0, 0, 1, $diaFin, $anno));
}
}

$fechas = array($anno, $diaIni, $diaFin);
return $fechas;
} // End of funtion retornarRangoDiasxSemana


where $anno = year
$semana = week number
Mar 30 '07 #1
0 1400

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Dave Smithz | last post by:
Help, I am sure this has been asked before but it is difficult to search for. Given a date, is there a function or a already written script out there that will allow my to get the previous...
2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
2
by: David Mitchell | last post by:
I have tried using the following code to count the specific number of each weekday but get a compile error "User defined type not defined" which I think relates to the first line of the function: -...
4
by: Mark | last post by:
Hi I have been trying to convert the week number to a range of dates that I can use. It should be fairly simple for you guru's out there but for us mere mortals it is beyond our grasp. I know...
14
by: deko | last post by:
This runs, but does not narrow to current week. suggestions appreciated! SELECT lngEid, dtmApptDate, Subject, Appt_ID FROM qry002 WHERE (dtmApptDate BETWEEN DateAdd("d",-weekday()+2,) And...
9
by: Ray | last post by:
I need to convert the normal calendar to show the week no., the period no. and the financial year. The financial year format is as follows:- Date start: 2 May, 2005 7 days a week, 4 weeks a...
1
by: David | last post by:
Hi, I have a problem with returning a value from an external function..... My asp page is basically a list taken from a database. A date record is written from the DB, then all the...
1
by: Hetal | last post by:
I am working on Visual Basic 2003 and i had a question about date functions. Is there a way to get the date range for a week based on the combination of 1) Week of the year and 2) Year? I mean, is...
3
Claus Mygind
by: Claus Mygind | last post by:
My date calculation do not seem to work out. I have a list box with a character string value of dates ie: 03/28/2009. I want to create a date range for the week. So I would like to get the...
0
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...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
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.