Get Dates Before From Last Week
<?php
//today date is: 2006-04-10 08:18:24
//last week is: 2006-04-03 06:23:10
$lastWeek=date('Y-m-d H:i:s', strtotime('-1 week'));
//How do I get any date before last week(2006-04-03 06:23:10)
//This show all date start from last week (2006-04-03 06:23:10) up to today (2006-04-10 08:18:24)
$result = mysql_query("SELECT * FROM $table WHERE dateCreate >= '$lastWeek'
//I want the opposite of this, from before last week, not from last week up to today.
?>
How can fixed the above code to get all dates in the database from before last week? Any idea?
View Complete Forum Thread with Replies
Related Forum Messages:
Day Of Week (dates): How To?
I'm building a website and in the database i store all information. Visitors can add events to the database, with the date the event takes play. Now, when in the database it says : 2006-01-01 i want it to show : monday january the first 2006 (something like that)my question is : how can i see wich day of the week it is, depending on the day specification in the date from the db AND (optionally i don't know how it will be coded) how can i change the day 'wednesday' to 'woensdag' wich is the same day but in my language.
View Replies !
Week Ending Dates
When a user logs on, he should have a drop down selection box of week ending dates that would include any week ending dates that he hasn’t completed time for, only going back as far to a specified date and then also the current week he is within and up to 1 week forward. The week ending dates should always be on a Sunday. The table I have is as follows; CREATE TABLE `techs_pay_weeks` ( `tech_pay_week_id` int(11) NOT NULL auto_increment, `tech_pay_week_ending_date` date NOT NULL default '0000-00-00', `tech_id` int(11) NOT NULL default '0', `tech_pay_week_hours` float NOT NULL default '0', `tech_pay_week_amt` float NOT NULL default '0', `tech_pay_week_approved` tinyint(4) NOT NULL default '0', PRIMARY KEY (`tech_pay_week_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; The tech_id is held as a $_SESSION[userid] when he logs in. I understand how to advance a date, but not from a dynamic date that should always fall on a Sunday, and a current Sunday at that.
View Replies !
Calculating Start And Ending Dates For A Week
Given a week number, how do you derive the starting date and ending date? I am trying to get the reverse of the yearweek function of MySQL. The yearweek function returns the year and week given a date. For example, yearweek(񟭂-08-01') returns 200231.
View Replies !
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 !
Offering Dates And Booked Dates In A Table As DATE Datatype Using MYSQL.
Availability dates in offering dates except booked dates. For Example: Offering dates are : 01-09-2005 to 27-09-2005 01-11-2005 to 30-11-2005 Booked dates are : 10-09-2005 to 23-09-2005 Availability dates should be 01-09-2005 to 09-09-2005 24-09-2005 to 27-09-2005 01-11-2005 to 30-11-2005 I am storing offering dates and booked dates in a table as DATE datatype using MYSQL. So, I want the above mentioned availability dates as a result.
View Replies !
Dates In Range Falling Between Existing Dates
The latest quandry I have is that I need to: a: check whether any dates in a date range entered by a client in a form (datefrom, dateto) conflict with any existing date ranges already in the database. -this is a check to see whether the dates that a customer is trying to book are not already booked- Obviously its easy to get the numbers out of the database (i.e. 28/12/2006 or whatever format) and from the form but how to I convert this 'range' actually into a range I can loop through that will return true if any of the dates are the same (i.e. already booked)? b: is similar in that I want to check how many of the clients entered dates fall into the pre assigned high, mid and low season ranges in the database and multiply each of those days by the corresponding price.
View Replies !
Get Dates Between Two Dates, Then Add To Table
I've got a form that inserts data into a database. Basically what it sends is a sets of dates. What I'm wanting is another set of inputs that also sends some dates. But before it adds them to the database I want to query the dates and find all of the dates between the two given ones and add them to the database as well. Code:
View Replies !
Day Of Week ?
Is there a way I can obtain the day of week - If I have the day, month, year ? (not via the time function - But from a database....) Im looking through the calendar and date functions -But can't locate anything suitable...
View Replies !
Day Of The Week?
is there a way to get the day of the week in php? i want to get the correct values monday, tuesday, wdenesday, etc. for the actual day it is.
View Replies !
Getting Day Of Week Out Of Datestamp
I currently have a datestamp in the format yyyymmdd. I want to pull the day of the week (Monday, Tuesday, etc...) out of that datestamp at any given time. Currently my code looks like this: $datearray = getdate($firstdatestamp); echo $datearray["weekday"]; When $firstdatestamp = 20000501 (or the first of May, 2000) the weekday returned is Thursday when really it should be Monday! I tried: echo date("l", time()); and it gives me the right weekday but only for the current date. I need to pass this my datestamp and am not too sure how.
View Replies !
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 !
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 !
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 !
Getting SQL Rows For A Week
I have a database that uses two date fields for tracking information. The first field is for the addition of the record and the second is for the expiration. I have a small section that I want to list records that will expire in the current week (or for that matter in the next 7 or 14 days). What is the syntax that I would use to call mySQL with to get that info.
View Replies !
Week Of The Month
I need to determine the week of the month (1-5) so I can rotate menus for a cafeteria. Is the following, which I know prints the week rather than storing it, the simplest or easiest way to determine the week? PHP Code:
View Replies !
File Of The Week?
I wish to add an automated "file of the week" feature to a site for users to download. I was having a little trouble explaining this.... So I ended up making these few points on the functions of the script I'm aiming for: - The script finds the folder with the files for the current week. (If the download was a wallpaper, there would be files for different resolutions, and therefore more than one file.) - Links are then made to the files. - Every week, the links are updated for the new files for the current week. I was thinking along the lines of putting the weekly files into folders named after timestamps and going from there... Is that the way to go? And how would it be done? I can't quite figure this out.
View Replies !
Printing Every Week
im trying to print a list of every Friday since a date defined. Let me try and explain. I want to define a date such as 2007-07-06 (which is a Friday) and then let php print each Friday since that date until today. For example, if the date defined was 2007-07-06 then it would print 2007-07-06 2007-07-13 2007-07-20 2007-07-27 2007-08-03 2007-09-14 But I want to also be able to format the date it outputs, so it might look like Friday 06 July 2007 Friday 13 July 2007 Friday 20 July 2007 and so on.
View Replies !
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 !
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 !
Day Of The Week Program
I am trying to write a program that will give me the day of the week without using the date function. I input the date and it's supposed to spit out the name of the day of the week. Here is what I have so far. I don't know quite what to do next. Code:
View Replies !
Days Of Week
I'm attempting to display information for today, the next day and the day after (so only three days worth). The first day is hardcoded to say now. I want the next day and the day after to be the abbreviated day (ie. Tue, Wed and so on). The problem I have with the following code is that now and the next day are the same. Thus, I have now (which is Tue), the next day (which is ALSO Tues - wrong!) and the day after is Wed. Here's the include: $return['mydata'] = array(); for($i = 0; $i < 2; $i++) { $attr = explode('"', $this->tag('blm:mydata',$i)); if(count($attr) > 1) { $day = array(); $day['when'] = $attr[1]; $day['image'] = IMAGES.$this->translate($attr[11]).'.gif' array_push($return['mydata'], $day); } } return $return; And here's the front-end page: echo " ".$stuff['mydata'][0]['when']."<br/>
View Replies !
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 !
Select Last Week
Is there a 'proper' way to select items with a date belonging to the previous week? I have this - SELECT n from table where YEARweek(a datestamp) = YEARweek(CURRENT_DATE - INTERVAL 7 DAY) && year(datestamp)=year(current_date) ... I think the flaw with that will come during the first week of January? Is there a better way?
View Replies !
Days Of Week In App
recommend for a best approach to populating a Days-of-the-Week table in an event-scheduler app? in my particular case, each day of the week relates to a daily drink-special for a bar. i'm trying to figure out my order of dependencies. here's a snapshot of my tables if i am going to add an event,i have to have it on a day of the week. that day of the week needs to have it's specials populated in order for it to exist in the Table. so, how should i go about "forcing" the Event Scheduler App User to first populate the Days-of-Week table so that when she adds data for an event, the dayys of the week will be available to input into the Event table?
View Replies !
Year Week
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.
View Replies !
Finding The Day Of The Week
I know i can find the day of the week for today by doing: $day_of_week = date("D",mktime()); But what if the date I want to find is not todays date but in a variable say current_date?
View Replies !
Getting Results For This Week
I have a table with a date field and I need to get the results for the next week. Basicaly it's checking estimated completion dates and getting the results for jobs that are due within the next week. Table looks like this JobID-->Primary EstimatedCompletionDate-->Date Year Make Model etc... I need to get a list that shows all estimated completion dates between today and 7 days from now. I know how to check for jobs due today, but it's the 7 days from now that is throwing me off, especialy if the month changes.
View Replies !
Week Calendar
how to to build a events week calendar? This calendar should only display all the week of the selected year!!
View Replies !
Recurring Day For Every Week
I need a function which gives me the list of dates for certain weeks (date for every monday for 6weeks) I am not aware of built in functions of PHP.... any easier way to do it...? Code:
View Replies !
Week Query
I'm trying to write a myphp query which will show me same-day results for today's day of the week. therefor show Today and all previous tuesdays. I can get each order's day of week by using "DATE_FORMAT( b.statusdate, '%a')", but what is the syntax for making this show where equal to today's day of the week.
View Replies !
Datetime Within Past Week
I have a series of records in a database. When each record is stored, the datetime is logged: $date = date("Y-m-d H:i:s"); Prior to adding a new record to the database, I want to run a query to retrieve all of the records uploaded in the last 7 days. I thought it would be easiest to: Pseudo Code: $newDate = $date - 7 days; select * from TABLE where DATE $newDate; Problem is I can't figure out how to subtract 7 days from $date and convert that value to a valid datetime object.
View Replies !
Current Week Number
how I can split the month out into 5 weeks... then to have the week number printed and when the current week ends it will increment to the next week number. For example today is 3rd of July, therefore we are in week 1 of the month. Next week will be week two. I want it to go back to 1 at the start of the next month though.
View Replies !
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 !
Handling Week Number
I have been reviewing some calenders classes and have notice that if u uses us written class with displays week number it ll by wrong for eu. so to my question how do you handle week numeration depenting on country? is there any simple solutions for this?
View Replies !
Mysql WEEK() Function
In mysql WEEK() function it specify the number of week of a specific date. For example January 02, 2006 will return a value of 2. Now my problem is how could i be able to determine the range of that value in a week like a value of 2 will be equal to January 1, 2006 - January 7, 2006.
View Replies !
Month From Week Number?
Has anybody here ever made or seen a function which when passed year and week number in that year returns month ? actually what I want is all records from db starting from six months back till now and group them by weeks, and some weeks may have no record so they won't appear in resultset. But I have to display zero against these weeks. display has to be in form of Number of Records in Week # x of Month y e.g Number of Records in Week 2 x of Month Jan So my solution is to get records from db by this query: .. where abs(Week(Now()) - Week(RecTime)) <= 26 this works ok but I don't have any idea of which month and week of month was 6 months ago. So I decided to get week number and year of 6 months back and then write my function get month form this info.
View Replies !
Delete Records Since A Week
I've been trying to delete records since a week and i'm not able to do it. Before with this script, i was doing so many things at a time and i was confused.But, now, i just displaying the records from a table N trying to delete them.Would somebody pls guide me. I just wanna set the delete flag(i.e, i want to set the RBS_DELETE column to Y or something) when i check a check box to delete it. I've some 5 records displaying on my form and i want to check 3 of them and when i check them and hit submit, i want the RBS_DELETE column to have some value. PHP Code:
View Replies !
Strtotime - Use Abbreviations For Week
I'm pretty sure I used to be able to use abbreviations for week (w), days (d), etc in strtotime (e.g. strtotime("-3d") = 3 days ago), but now it doesn't work as expected unless I specifiy the whole word ("-3 days"). Has anyone else come across this ?
View Replies !
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 !
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 !
Constraint Using The Days Of The Week?
I am developing a property application where I have 5 members and only want 1 member a day to choose their property for the "property of week" section. So I want to assign a day to each member. Mem1 - Mondays Mem2 - Tues Mem3 - Wed etc.. Each member will have there own unique logon so if Mem1 logs in on Monday, they will have the "property of week" option avaliable to them. Mem2 will have it Tuesday and so on.
View Replies !
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 !
|