Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Code To Calculate Date Range In A Given Week


Well I'm facing a problem in calneder and want your
help. I want to calculate the date that fall in a give
week but am not able to get the method for doing so.

Let me explain it with an example. Suppose i select
teh 25th week of the present year(i.e 25th week of
year 2006) then how can i calculate the days that fall
in that week.




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
How To Calculate The Day Of The Week By A Given Date.
I'm currently working on a (simple) calendar system which allows registered users to add an event to the calendar. The table EVENT stores info about the author, date and description of the event.

I then managed to output a list in which only events of this year are showed and are grouped together by months. And now I only need one more thing to complete the script. I want to output for every event on which day of the week it occurs (monday - sunday). I've looked around for tutorials but haven't found a basic one.

View Replies !   View Related
Calculating Week Range
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 Monday before the date given?

This is so that given the current date, I can show all events that are happening for that week. I also will want to do the same for the month. I know I could go about writing algorithms to calculate this, but I am sure this is something that has been done numerous times before.

Also is there anywhere out there built an easy to plug in calendar view function that rather then my user manually entering the dates they want to select,can just select a particular date?


View Replies !   View Related
Display For The Week Of (fridays Date Of The Week).
I have a report that people can access online and it generates data for a given week until friday. In the title and on the report, I want to display For The Week Of (fridays date of the week).

Instead of writing a huge if - then statement array - is it possible for to simply have an expression that figures out what day it is and then tells me Fridays date - has anyone ever done anything like this.

View Replies !   View Related
Specify A Date Range And Have Only Entries That Are In That Date Range
I have this database with lots of info all time stamped with this format "May 15 2007  9:44AM".  What I would like to be able to specify a date range and have only entries that are in that date range be pulled from the table so that I can post the results. I know this must be possible but I have no idea host to even start.

View Replies !   View Related
Calculate Date
I have a date

11-07-2007 22:06

and i want to know how to calculate 4 hours ahead and create a count down system

$date_now
$date_4hours

$countdown = $date_now - $date_4hours;

View Replies !   View Related
Getting Day Of The Week From A Date
I tried searching the old postings, but to no avail. I am trying to figure out a way to get the day of the week from a date. Basically, I have a date in the format of 05/02/2003 (but I can change that format easily) and I need to have my program figure out which day of the week that was. All of the dates that I have will have already passed.

View Replies !   View Related
Date Of The Week
Can anyone help me? I am trying to work out the timestamp for the first DATE (not day) of the current week and last date of the current week. Any ideas?

View Replies !   View Related
Date To Week # Fct
I'm searching a PHP function that would translate a date in the following
format yyyymmdd to the week number in the year...
ex : 20040128 => 5
i.e. jan 28th 2004 gives week nb 5 in 2004.

View Replies !   View Related
Week Before Date
Im looking to get the date 7 days ago. I know how to do 7 days ahead:

$timeStamp = strtotime($oLastBatchDate->Last);
$timeStamp += 24 * 60 * 60 * 7;
$NextBatchDate = date("Y-m-d  H:i:s", $timeStamp);

However, does anyone know how to do 7 days back?

View Replies !   View Related
Date And Week
I am looking for a way to determine the week of the year if i have a date.i know that
date("W"); give me the week Number but not sure how to determine the week based on the date.

View Replies !   View Related
Week To Date.
how i can make a week number to a date string. Ex. week 1 ---> 1 Jan. till 7 jan. Date format is not important.

View Replies !   View Related
How To Calculate Date Difference?
Any one can suggest me how to calculate the difference between 2 dates and it shouldn't be more then 5 years. So pls tell me how to code this?

View Replies !   View Related
Calculate A Date Diff
Does anybody know of a script where I can calcullate a datediff and make a pop-up apear a week before a certain date.

View Replies !   View Related
Calculate Dates Given Beg And End Date
I am trying to figure out how to generate a listing of dates using the following known values:

begDate = 2007-07-03
endDate = 2007-08-30
recurDates = Tue|Thu

Question is how do I generate the YYYY-MM-DD for each of the dates between begDate and endDate for each of the recurDates?

View Replies !   View Related
PHP Date Range?
Is there a way I can get PHP to echo a date range, and have it update weekly? I want it to show "Monthnow", "Datenow" - "Monththen", "Datethen" (Where Month/Datenow is the last recognized Wednesday, and Month/Datethen is the next upcoming Wednesday). Example, for the current week, the page displays: July 23 - July 30.

I'd like it to update that automatically on a weekly basis, if possible, using the date/time features of PHP. (I have no database).

View Replies !   View Related
Date Range
The >= statement below returns rows, but when I add the 2nd statement I get nothing. Is there a better syntax to use with MySQL 4? The <= doesn't work by itself either. Looks like <= can't be used at all.

AND CloseDateTime >= &#3908;/01/2007'
AND CloseDateTime <= &#3912;/31/2007'

View Replies !   View Related
Date Is Within A Range
Suppose i have 2 dates as range i.e: 10-03-2005 to 20-03-2005. Now i want to check if 15-03-2005 falls in the above range or not.

View Replies !   View Related
Date Of The First Day From A Given Week Number
I need some help to figure out the date of the first day in a given week number. Let's say that I pick week number 23, I want to retrive the day of that monday in week 23..

I've been searching the net for days without any result.

View Replies !   View Related
Date Out Of Week Number?
I would need to get a date out of a week number, for example for week 52 the first date, 25/12. In my system the user inputs a week number, and then I would like to display a popup list of all seven dates for that week, for her to choose from. Is there a handy function to do this, or can you think of any way to achieve this?

View Replies !   View Related
Date Function For Week Before
Im looking to get the date of a week before a certain date For example:

      $iLastDate = date("Y-m-d H:i:s ");
      $timeStamp = strtotime($iLastDate);
      $timeStamp + = 24 * 60 * 60 * 7;
      $NextBatchDate = date("Y-m-d  H:i:s", $timeStamp);

This is for a week ahead, how do I do a week before?

View Replies !   View Related
Work Out Day Of Week From Given Date
I'm using a date picker to choose a date. the format of the date entered into the textbox is yy/mm/dd

From this how can I work out the day of the week from the entered date? I need this as the first day has to be a sat, and if it isnt my form will tell the user to choose a saturday.

Is there a simple way of doing this?

View Replies !   View Related
Week Numbers To Date
I like to know how i can make a week number to a date string.

Example week 1 ---> 1 Jan. till 7 jan.

Date format is not important.

I have a calendar that has week numbers on it (week 1 till 52)

But the customer wants it to have dates also on the form (mouse over or something. I don' want to adjust the Whole site and DB.

View Replies !   View Related
Calculate Date Of Birth From Unixtimestamp
I am having a table that stores  datwe of  birth in  unix timestamp (now() for MySQL) . I want to display the name of all user along with their age. Can anybody help me in this?

View Replies !   View Related
Calculate Age Based On Date Of Birth
I am trying to validate whether or not a date of birth entered in dd/mm/yyyy format is between 16 and 69 years old.  Suppose we have todaysdate = 18/04/2007

The minimum allowed date of birth would be 18/04/1991 and the maximum allowed date of birth would be 18/04/1938.  I have looked at using strtotime but this only does dates from 1970 (I think)

View Replies !   View Related
Calculate How Much Days From Past Date Until Now
I want to know how to calculate number of days from past date(obtained from database) until now(current date).The situation is,I want it display how long that user have joined the group on his/her profile page.And also,I want it to display Code:

View Replies !   View Related
Submitting Date Range...
<?php
$query="SELECT SUM(hours) from log WHERE
pid='$'pid' AND uid = '$uid' AND
date >= '$start_date' AND date <= '$end_date'";
?>

Does this look right? I'm gonna create a form using genDateSelector(). Eg. to allow user to select a start date and end date to view summary report for that date range only. What am I missing?

View Replies !   View Related
Displaying A Date Range
I would like to display a user specified date range e.g Monday to Monday next week or maybe Monday next month. When I have the basic function worked out I would like to get Data from a Mysql Database. here is what I have thought about. Code:

View Replies !   View Related
Date Range Function
Is there any function i can use, somthing like date range, like all the dates between:
6/8/2001 "to" 12/8/2001 .

View Replies !   View Related
Selecting Date Range
How do I query a date range? I have a date column in my mysql table. I want to select a range of rows between : Ex. 2007-08-05 through 2007-08-30 .

I also would like to have the page that sends the query as a form.. option value that shows all of the available dates, so i can select a from date and a to date.

View Replies !   View Related
Selecting Within A Date Range
Basically I want to list all events that are active on a particular day. The events are saved in an SQL table with a start date and a duration. The following code appears to work but only returs one event when there should be 3! Code:

View Replies !   View Related
Query Date Range
I have a table which holds a bunch of dates

id   datefrom       dateto
1    2007-02-22   2007-03-05
2    2007-05-13   2007-06-23
3    2007-05-25   2007-07-23

the `datefrom` and `dateto` are dates in the format YYYY-MM-DD, the `datefrom` means the date the event starts and the `dateto` means the date the event ends.

What I want to run a query on this table and return any rows which have todays date between the 'datefrom' and the 'dateto'.

Does that make much sense?

View Replies !   View Related
Date Range Validation
I'm a sysadmin who just took over a php application and have no php training. I have this function: Code:

View Replies !   View Related
Selecting A Date Range
I have a similar problem where i have to display the records in a date range which will be selected by the user in two dropdown boxes picked up from the date field. The database contains numerous instances of similar dates for different managers and team leads.

The database contains fields :- Sr.No, Date,Manager,Team Lead, Attendance and calls taken. How can i populate the drop down with one instance of repeating dates in two drop downs so that the user can select the date range and data can be displayed to the user in a proper formatted row.

View Replies !   View Related
Date Range Display
I need to make this website. I want the PHP code to do the following...

On
05/21/06 - 05/23/06
echo "blah blah..1"
05/24/06 - 05/26/06
echo "blah blah..2"
05/27/06 - 05/30/06
echo "blah blah..3"

I started doing PHP today but I've done C before so it's not that far off. I know how to do it with a switch function but then I'd have to input every day
case "5/21/06":
case "5/22/06":

There are going to be A LOT of dates, and I'd prefer to keep them in daterange mode. but I have no idea how to do this.

View Replies !   View Related
Select Date Range
I have to run a query in mysql where records from a date range are selected. I need to know how to make the query of following type:

select * from datetest
where date between &#3911;-11-2001' AND &#3901;-10-2009'
order by date desc

It will be great if someone can tell me which is the best format for dates: Code:

View Replies !   View Related
How Many Sundays In A Date Range?
Dates come in the format 2006-02-16 (year-month-day) for example. I have this rather complicated proceedure using explode(), then mktime() that will give me the number of days in the date range, which could then be used in a loop that would step through the days.

Then I would need to go back from mktime format to XXXX-XX-XX format (not sure about that part yet), REEXPLODE the darn thing in order to use jddayofweek(gregoriantojd($mo, $day, $yr), 1) to get the day of the week that could be used in a counting loop.

I know this description is very general, but all of it does work (except for the format change I indicated I'm not sure how to do yet).

Just wondering if anybody knows of a more elegant solution. I'm not looking for "Here's the code", just more like "I know of this great little function or proceedure..." .

View Replies !   View Related
Date Range From Mysql
I am trying to make a select statement that will only get records from the current month. The dates are all stored in mysql in the standard format (yyyy-mm-dd), is there anyway to compare this field with a current month function.

View Replies !   View Related
Figure Out Date Range
What is the best way to figure out the date range of a week. I thought some like this

$day = -7;
$date = $currentdate - $day;

[sql]
Select $t_task,$tot_time FROM time WHERE username='$usrname' AND $t_date=<$new_date AND $t_date=>$current_date
[sql]

View Replies !   View Related
Date Range Query
how to make a php mysql query that would return only data inserted in the last 24 hours? I have a dateSubmitted datetime field in the database already.

View Replies !   View Related
Date Manipulation - Find The Day Of Week
I have to do an events calender for a church. The events display will
be limited to that week. If someone went in today Wed 24th I want to
display 21st to 27th. I dont want any code samples, just the functions
that find the day of week and a function that can (in this case)
subtract 3 days to get sunday and add 7 for saterday. I can do the
rest.

View Replies !   View Related
Getting Day Of Week From User Defined Date?
is there a way to do this? e.g. i have three drop down boxes in html asking the user for day (1-31), month, year (2007 or 2008) i then have:

// get user input
$start_day = $_POST["start_day"];
$start_month = $_POST["start_month"];
$start_year = $_POST["start_year"];
//echo $start_year;

$the_date = $start_day . "/" . $start_month . "/" . $start_year; echo $the_date; say then i get an output as 13/10/2007 if the user enters that date, is there a way to get what day of the week this is?

View Replies !   View Related
Find Out What Day Of The Week A Certain Date Falls On
I would like to find out what day of the week a certain date falls on. i know the command for doing it for today.

$today = date("w");
anyone know how to do it for a variable date? like say 2007-11-25

I can't seem to find that. I can write some whacked out function to it. But i was hoping for an easier way.

View Replies !   View Related
Date That Is Formated With The Week Number Of A Year. Date("W");
I have a date that is formated with the week number of a year. date("W");

this defults as monday being the first day of the week. Is there anyway I can dynamicly set which day I want to be the start of the week?

View Replies !   View Related
Calculate The Nearest Date To Display To The User
i've got a series of events stored in mysql that each have a date associated with them via year, date, month. all int fields. how i would calculate the nearest date to display to the user. ie, if today's date matches a date display that, otherwise display the next closest.

View Replies !   View Related
Calculate The Number Of Days Between A Given Date And The End Of The Month.
I was hoping someone can help me with a date calculation. I'm trying to calculate the number of days between a given date and the end of the month. I have a form with three drop down boxes: month, day and year.

A user will submit a date using these drop down boxes. Based on their submission, I need to determine the number of days to the end of the month from the date which was submitted.

For example, if the person submits March 15, 2007 and the last day of the month of March is March 31, 2007. The number of days between the 15th and the last day of the month is 17.

How do I begin programming this calculation? Since the last day of the month differs from month to month (28th, 30th or 31st) I cannot figure out how to determine the last day of a given month.

View Replies !   View Related
Creating A Date Range Query?
If I have a date field, and want to select all records that are older then 30 days from today, is there a way to query MySQL for this? Code: $todaydate=date("Y-m-d");

$query = "SELECT * FROM members WHERE joined_date = '$todaydate-30' "; I know this will not work, but it's functionaly what I am trying to do.

View Replies !   View Related
Date Range Query Issue
I have a database which contains events, the structure has two date fields, one is called "datefrom" and the other one is called "dateto", these two fields contain dates in the format YYYY-MM-DD.

"datefrom" represents the start date and then "dateto" represents the end date.

I have a query which returns all rows which have todays date within the start and end date, but it doesnt seem to be doing this correctly all the time, if at all. Can anyone spot any issues I might have with it?

My query is

$eventssql = "SELECT * FROM events WHERE type = 2 AND datefrom BETWEEN CURDATE() AND CURDATE() + INTERVAL 6 DAY OR dateto BETWEEN CURDATE() AND CURDATE() + INTERVAL 6 DAY LIMIT 10";
$eventsquery = @mysql_query($eventssql,$connection) or die(mysql_error());
Make any sense?

View Replies !   View Related
Query Date Range Select
how do i make a query that select between today and a week from today.

View Replies !   View Related
Date Range In MYSQL Query
I'm trying to extract data in a certain range of date (say 1 month's worth), but my results aren't what I'm expecting.  Can you guys have a look at my code and suggest what may not be coded properly?

function display_archive($month) {
  $tempdate = $month. " 1, 2007";
  $startdate = date("F d, Y", strtotime($tempdate));

  $tempdate2 = $month. " 30, 2007";
  $enddate = date("F d, Y", strtotime($tempdate2));

  db_connect();
  $result = mysql_query("select * from blog where entered BETWEEN '$date' and '$enddate'");
  $num_rows = mysql_num_rows($result);
}

View Replies !   View Related
Query Based On Date Range?
I'm using php/mysql, and I want to write a query that will continually return results for records that fall within 7-day dates ranges. So, I want a query that will print out records for:

12/1/05 - 12/8/05
12/9/05 - 12/16/05
12/17/05 - 12/25/05

.... infinity

Can I accomplish this using a mysql query, or do I need to do something fancy with php, or both?

View Replies !   View Related
Allow User Specify The Search Date Range.
I am trying to write a query string that will allow user specify the search date range.
My records have a column with the "date" in the following format 0000-00-00. I can specify the FROM and TO range in the search form. Both FROM and TO have month and year.
Having difficulties with the actual query. PHP Code:

SELECT *
FROM mytable
WHERE tbl_date(MONTH) < ".$FROMmonth."
AND tbl_date(YEAR) < ".$FROMyear."
AND tbl_date(MONTH) > ".$TOmonth."
AND tbl_date(YEAR) < ".$TOyear."


Doesn't look right, does it?

View Replies !   View Related
Calculating A % Based On Date Range
I want to get the percentages for the 2 possiable values in TransResult and I want this done by date, so I can go backwards to compare what was done in the past months to what is done in current month. This is what i have come up with so far, however my _total is giving me ALL records in the table not this months records, so my percentages are off, aside from the total the values it is calculating are correct.

SELECT TransResult, COUNT(*) AS HowMany, (COUNT(*) / _total ) * 100 AS Percent FROM tbltranslog, (SELECT COUNT(*) AS _total FROM tbltranslog) AS myTotal WHERE MONTH(Date) = MONTH(NOW()) +0 GROUP BY transresult.

View Replies !   View Related

Copyright © 2005-08 www.BigResource.com, All rights reserved