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

2 weeks past date(mysql)

pradeepjain
563 512MB
Hello every one,

i have a form with a date .i need to display records of the form from the database and display all records of 2 weeks from the present date i.e 14 days record..so how to get the date 14 days back from current date


Thanks,
Pradeep
May 29 '08 #1
5 2367
hsriat
1,654 Expert 1GB
strtotime may hep you.
May 29 '08 #2
pradeepjain
563 512MB
strtotime may hep you.
This is the sql command i am using.. i have put "??" for where i have doubt where i need to have a 14 day old date....how to get it i dont know....

Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.   ID, raised, ext, location, description, type,
  3.   DATE_FORMAT(rdate,'%d %M %Y'),
  4.   action,status,
  5.   DATE_FORMAT(cdate,'%d %M %Y'),
  6.   remark,handle
  7. FROM complaint 
  8. WHERE status='open' OR (rdate <= curdate() and rdate >= ??) 
  9.  
May 29 '08 #3
hsriat
1,654 Expert 1GB
This is the sql command i am using.. i have put "??" for where i have doubt where i need to have a 14 day old date....how to get it i dont know....

$str_sql="select ID,raised,ext,location,description,type,DATE_FORMA T(rdate,'%d %M %Y'),action,status,DATE_FORMAT(cdate,'%d %M %Y'),remark,handle from complaint where status='open' or (rdate <= curdate() and rdate >= ?? )

What's the format of rdate?
May 30 '08 #4
Atli
5,058 Expert 4TB
Hi.

You can use the DATE_SUB function to do that.
Expand|Select|Wrap|Line Numbers
  1. SELECT DATE_SUB(NOW(), INTERVAL DAYS 14)
  2.  
May 30 '08 #5
Atli
5,058 Expert 4TB
I've merged the duplicate thread you posted in the PHP forums into this one.
Please don't double post your questions.

And please post you code inside [code] tags, preferably formatted in such a way that we can actually understand it.

Thanks
May 30 '08 #6

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

Similar topics

4
by: Neil | last post by:
Hi, I hope this question isn't too far off topic....I'm almost at my wits end trying to figure this out. I have a Mysql database and I wish to automate the backup of the database because I...
0
by: Fabrizio Tivano | last post by:
Hello dear all, i have 2 table :tbl1 and tbl2 i need to make an update on tbl1 based from tbl2 records. Ex: update tbl1, tbl2 set tbl1.conf='1' where tbl2.name='AD' and tbl2.date=tbl1.date;...
0
by: Philip Stoev | last post by:
Hi all, Please tell me if any of this makes sense. Any pointers to relevant projects/articles will be much appreciated. Philip Stoev http://www.stoev.org/pivot/manifest.htm ...
1
by: - | last post by:
what is the function to check whether a date, eg 2005-02-44, exists? in php, there is a checkdate() function.
2
by: Phil Nospam | last post by:
Hello all, I was browsing through the reference manual on the mysql.com web site and found the following code examples for some date/time functions: mysql> SELECT STR_TO_DATE('00/00/0000',...
0
by: Sam Flywheel | last post by:
Hello, all: I am pleased to announce that the MySQL Journal is moving forward. During the past two weeks, I've been discussing the journal with MySQL AB, and the plan that's been devised...
1
by: Lennie De Villiers | last post by:
Hi, I'm running PHP 4.4.2 and mySQL on MS Windows XP Home Edition in IIS 6.0. When I try to connect to mySQL from PHP I get the following error message: Warning: mysql_connect(): Client does...
4
by: Chris Tate-Davies | last post by:
Hello. I have a generic table used for many different generic functions. the fields are mainly varchar's but one of these varchars contains dates (in the format dd/mm/yyyy) for one reason or...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
9
by: TC | last post by:
Hi. I have some ASP written in VB.net which is currently installed on a customers server. The asp connects to a local MySql database and retrieves data for the customers customers. If you see...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.