SQL - Selecting All Records From Past 30 Days...
How do I only display records solely from the past 30 days with an SQL query, using the 'date' field in my database? The column in the table is called 'date' and uses date type :
date date No 0000-00-00
I have tried :
DATE_SUB(CURDATE(),INTERVAL 30 DAY)
but to no avail.
View Complete Forum Thread with Replies
Related Forum Messages:
Add Days To A Date In The Past.
I'm trying to add days to a date in the past. I know this adds 30 days to today's date: PHP Code: $newdate = (date('Y-m-d', strtotime('+ 30 days'))); But let's say I have a date variable: PHP Code: $pastdate = ��-05-06'
View Replies !
Selecting Dates In The Past Of Future (MySql)
i have a mySql query that looks like this: $sql = "SELECT * FROM events ORDER BY event_date DESC;"; it selects everything in a database and displays all records in it in order of there date. what would i have to add to this quray to make only select records that are in the past or future?
View Replies !
Selecting Posts From Past Or Future Months
I have a WHERE clause that selects all the rows where the date column is within the current month. Code: "WHERE date BETWEEN DATE_FORMAT(CURDATE(), '%Y-%m-01') AND LAST_DAY(CURDATE())" How can i make it select posts that are X months in the past or X months in the future?
View Replies !
Displaying Records After 2 Days
I trying to display only records that are 2 days old so the owner of the site can preview new records before they are available to others, this is what I've got so far... $sqlquery = "SELECT headline, news, date_format(date,'%M %D %Y') as time FROM $table WHERE date < NOW() ORDER BY date DESC"; is there a way to extend it by 1 or 2 days, i've tried the TO_DAY function but couldn't get it to work either.
View Replies !
Display Records 30 Days From Now
I am trying to display records that are 30 days from the current time. Someone suggested the following: select * from table WHERE date_column BETWEEN CURDATE() and DATE_SUB(CURDATE(),INTERVAL 30 DAY)
View Replies !
Displaying Records That Are Less Than 30 Days Old.
I have records that are dated using date('y,m,d') when they are created. Would like to only display records that are less than 30 days old. So, IF record is older than 30 days - do not display. Here is my code: $arr = $db->getArray("SELECT * FROM table WHERE id = '$id' ORDER BY date ASC");
View Replies !
Update All Records In A Database 364 Days
I have a calendar with events for this year in a SQL database that I would like to use for next year too (the events will remain the same). The days of the week are important; what is on Monday, November 6, 2006 should be on Monday, November 5, 2007. I will copy the existing table to another table for the next year, so what I would want to do is update the dates to be 364 days from each date. Does anyone know a command that I can update all records by 364 days? The table is practice07 The field is PracticeDate (that holds the date that I want to update)
View Replies !
Selecting Records
i need some code that will select all the records in between two dates based on someone entering in these two dates. problem is i have no idea how to code it as i dont fully understand the coding behind it. here is the code <form name="getdates" method="post" action=""> From: <input name="date1" type="date"> To: <input type="date" name="date2"> <input type= "submit" name="datesbetween" value="Get Dates"> </form> <?php $date1 = date(d,m,Y); $date2 = date(d,m,Y); if ($called){ return false else return true $date = mysql_query ("SELECT * FROM calls WHERE calls.called "); }...
View Replies !
Selecting All Records
I am currently building a PHP/MySQL site, and am stuck creating a particular querey to do with and events calendar kind of thing. I have a table on my database where one field is a datetime type field with the date and time of the event in. What i am wanting to do is use the WHERE in my querey to select all records where the datetime field is in the month of October 2004 for example but i cant seem to figure out how to get this working.
View Replies !
Selecting Random Records
I want to select a record from the table in random fashion. Like $myrand=rand(1,25); select * from faltu where bekar='$myrand' but here the problems is that rand() returns repeated values. So I used srand() but still the repetition is there. I have 50 records in the table and want to select only 25 of that one at a time. How do I do it.
View Replies !
SELECTing And UPDATEing All Records
SELECTing and UPDATEing all records In MySQL database table I want to SELECT each record, change the way a date is formated in one field and write this new format to another field of that record. I want the script to continue through each record and do the whole database table. I am having a problem with my do while loop. The first record is UPDATE alright, but the I get the error: Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:websites est.php on line 43 Line# 43 is $Row = mysqli_fetch_assoc($QueryResult); How can I do this? Code:
View Replies !
SELECTing And UPDATEing All Records
In MySQL database table I want to SELECT each record, change the way a date is formated in one field and write this new format to another field of that record. I want the script to continue through each record and do the whole database table. I am having a problem with my do while loop. The first record is UPDATE alright, but the I get the error: Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:websitesest.php on line 43 Line# 43 is $Row = mysqli_fetch_assoc($QueryResult); How can I do this? Code:
View Replies !
Create A Sql Query That Will Select Records By Selecting A Month
I am trying to create a sql query that will select records by selecting a month. So for example I have to create a query rhat will select all entries between 1st jun and 1st july (1117609200 and 1120201200) which should not be that hard. Is there a function that will generate what the timestamps should be automatically instead of me having to calculate them manually.
View Replies !
Get € Past A XML Parser
I'm having troubles getting the euro sign through an XML parser. With the following test code: <?php $string = "<root><test>€</test></root>"; $parser = xml_parser_create(); xml_set_character_data_handler( $parser, 'cdata' ); xml_set_element_handler( $parser, 'starthandler', 'endhandler' ); if( !xml_parse( $parser, $string ) ) { print xml_error_string( xml_get_error_code( $parser )); } function cdata( $p, $data ) { ...............
View Replies !
Variables Past By Get And Post
I'd like a generic include that goes at the top of all pages that mysql escapes the variables past to the script. Is there a way to refer to the each of the variables past, for example (in pseudo code): for(each $XX in (list of get/post variables)) { $$XX = mysql_escape_string($$XX); }
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 !
Past Dates Script
I maintain a website for a musician who has been actively touring for more than 30 years. One of the biggest requests I get is for past tour dates. I have thousands of dates, But I have not been able to find any kind of efficient way of cataloging and displaying the dates. Since I'm always getting new dates in (from old magazines, newsletters, etc), I need a way to enter them via a form and have them sorted automatically by date, city or venue. I'm not a programmer, by any means, so something pre-made would be better, but my budget is nonexistant.
View Replies !
Get The Values For The Past 11 Months
I want to get the values for the past 11 months somehow. The problem with the code below is that it duplicates december and january for some reason. If I output all of the variables I get two "12" and two "01". Code:
View Replies !
Delete Past Events
There was a post similar to this one but I can't find it right now. All this is to do is get rid of past concerts if it is before today. I do have DELETE privelege for the user $today = date("Y-m-d"); // Delete past events $sql = "DELETE FROM tbl_events WHERE eventDate < '$today')"; $query = mysql_query($sql); no clue why it doesnt work
View Replies !
Won't Get Past The If() Unless I Put A '!' Infront Of The Isset
I have made some code of which doesn't work, it looks like it should and my friend has checked it too, yet we see no problem. The form part goes: <form action="EP" method="post" name="f" class="style1" id="f"> <p>PASSWORD: <input name="pas" type="password" id="pas" /> </p> <p> <input name="sub" type="submit" id="sub" value="RUN" /> </p> </form> The php bit that gets the code goes: if(isset($_POST["pas"])) *not "field"* I only give the if bit *various secret codes and things below*. It won't get past the if() unless I put a '!' infront of the isset. This gives me the impression that the variable hasn't been set, I've tried it on 3 different servers and no luck on any.
View Replies !
Get Past Browser Cache
I've got a site on a hosted virtual server. I'd like to know the truth of what is going on, but I can't get past my browsers cache. There is some kind of error in my code that occurs on a given line. When I comment out that one line, everything else seems to work. When I uncomment that one line, the browser simply shows what was last on screen the last time the code was working. That is, if I write echo "hello"; while the line is commented out, then I change the line to echo "goodbye"; and I uncomment the line and hit the refresh button on my browser, the word hello will remain on screen. Neither FireFox nor IE will show me the truth of what they are seeing, either that be nothing or an error message. How to get around that?
View Replies !
Pagination Of Results Won't Get Past 10. Why?
I have a small search engine for a database of songs. I've divided the search and results codes into seperate pages. For some reason I can't get my results to go past 10 even thought I know that there are more records then 10. Can anyone tell me what I'm doing wrong here? Code:
View Replies !
IP Adresses (getting Past Proxy Servers)
i can capture IP addresses with no problem using $HTTP_SERVER_VARS['REMOTE_ADDR']. this works for people with static IP addresses just fine, however people who use DSL have dynamic IP addresses and i can't match people up to their IP address this way. i need this for a site where i want to only allow people into the site from the IP address that i got from them the first time they registered, i can't use $HTTP_SERVER_VARS['REMOTE_ADDR'] for this, apparently. the only way i've seen people claim to get past proxy servers is on php.net where they said that $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'] would work. however, my php engine doesn't even seem to recognize this variable. this is also important in banning people from message boards and other IP specific situations. are there any other ways of tracking users specifically by what machine they are using?
View Replies !
Time Like Machine To Capture Website In Past
I want to create a section that will allow users to visit the site as it was in the past. All the data of the site is stored in MySQL. Here is what I'm having trouble with. A few sections are updated daily and a few only weekly. So if someone enter 10 Dec 2002 I want the site to show that days stuff. However if on this day section D contained the same content as 8 Dec 2002 because there has been no change how would I show this? I was thinking of using strtotime() with a -day type function? Conceptually would this work? How would I cross reference or search for the closest date in the past to the date being selected? Should I use Unix timestamp or just getdate() and then plug the values into seperate fields that match for day, month, year? I'm trying to understand the value of Unix timestamp and have read numerous post but I do not see why it is more useful than just plugging numbers into seperate fields for day month year. Thanks for any help you can give me.
View Replies !
Displaying Priorty Records And Normal Records In The One Dataset.
I have a page which displays the records from the database and uses paging to display the records in groupes of 10 per page. I now want to be able to show results depending on the database field (display) in the database (can be set to either "full" or "limited"). If the record and the field display is equal to "full" i want to then display this record at the top of the record set and display all the fields. If the record is equal to "limited" i want to display different results and they must show after all the records which are equal to "full". I can't output two different recordsets as i use paging and only want to show 10 records per page. Code:
View Replies !
DELETE RECORDS - Database Adding New Records
iv got the database adding new records, and now I want it to display all of the records that are there buy name and id number, then i want u to be able to type in the id number of the customer u wish to delete and it shoudl delete it, sounds good buts its not actually deleting the record. it says it does, but its not doing it. Code:
View Replies !
Problems With The Listing Of Records, Editing Of Records
I'm having problems with the listing of records, editing of records, and deleting of records. I'm not sure what I'm doing wrong. The listing script is calling the add entry script. So I add the record, the database is updated, and nothing else happens. I don't get a list of records from that table. When I did SQL programming off the mainframe, you did a simple select statement. I'm not sure why the PHP list script is calling the add entry script. Code:
View Replies !
Last 7 Days
I am trying to run a query to get the last 7 days in the following format: Code: <a href="roundup.php?news_date=20060523">Tuesday, May 23, 2006</a><br> <a href="roundup.php?news_date=20060522">Monday, May 22, 2006</a><br> <a href="roundup.php?news_date=20060521">Sunday, May 21, 2006</a><br> <a href="roundup.php?news_date=20060520">Saturday, May 20, 2006</a><br> <a href="roundup.php?news_date=20060519">Friday, May 19, 2006</a><br> <a href="roundup.php?news_date=20060518">Thursday, May 18, 2006</a><br> <a href="roundup.php?news_date=20060517">Wednesday, May 17, 2006</a><br>
View Replies !
How To Get -7 Days
how can i query the last seven days of my table (table )waytogo id (int auto increment) | dates (datetime format) 1 | 2005-11-23 08:54:32 2 | 2005-11-21 09:32:45 3 | 2005-11-12 12:43:22 4 | 2005-11-19 02:30:00 etc...
View Replies !
Days In A Calender
I am trying to write a calender display that shows the days of the month accross the top of a table, and people's names down the side. One of the things I would like to do is to change the colour when the days are Saturday or Sunday. PHP Code:
View Replies !
Dates Of $day In The Next $n Days
how would I go about working out the dates (timestamps) of the day $day (e.g. Monday, Tuesday, &c) in the next $n days. So if $day was Monday and $n 28 I would want to find out the dates in the next 28 days that are a Monday. The problem is that I am not sure about the logic side of the problem. A crude solution that I can think up is doing something like PHP Code:
View Replies !
Add Days To Date
I have a date assigned to a variable $firstPay and another variable $totalDaysTo which has the number of that I want to add to the variable $firstPay to get some future date. I'm not sure how to wright the code for this one.
View Replies !
Days Calculation
i can't seem to get this what im trying to do is work out the elapsed time in DAYS from 2 dates code is: $time_now = time(); $d2 = date('Y-m-d H:i:s', $time_now); $d1 = date('Y-m-d H:i:s', strtotime($ng_date)); $days = ceil(($d1 - $d2) / (60 * 60 * 24)); when echoing out it produces: 2007-06-02 16:53:24 2007-08-27 18:00:51 which is right, but $days echoes out as 0.
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 !
Select Last 7 Days
I have a load of dates in my 'orders' table in this format 2006-10-25 and i need to be able write a query that would select all orders in the last 7 days - in fat it can be any number of days but that's a variable from a select menu. what i can't work out is how to write the query : SELECT * FROM orders WHERE ord_date ..(is between x days ago and today)?
View Replies !
Adding 7 Days
I have been tearing my hair out trying to work out how to add 7 days onto the current date. This is how i am calcualting the current date: PHP Code: // Set the timezone for getting the currrent local time $timezone = +9; Code: <input type="hidden" name="date" value="<? print gmdate("Y/m/d @ H:i:s", time() + 3600*($timezone+date("I"))); ?>"> This is being stored in the DB like this: Code: $SQL = $SQL . " date_posted DATETIME NOT NULL default ��-00-00 00:00:00', "; So, what I am trying to do is create a variable called "Expiry Date" which I want to be $date + 7 days .
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 !
Strtotime With Days
On this - "next Thursday" is that next thursday or the next thursday ie: on wed will it show tomorrows time or the next week? PHP Code: <?php echo strtotime("now"); $timestamp = strtotime("now"); echo "Â Â "; $str = date('l dS of F Y h:i:s A', $timestamp); echo $str; ?> <p> <?php echo strtotime("next Thursday"), ""; $timestamp = strtotime("next Thursday"); echo "Â Â "; $str = date('l dS of F Y h:i:s A', $timestamp); echo $str;
View Replies !
|