Solved

Date within mySQL query

Posted on 2011-09-16
5
318 Views
Last Modified: 2012-05-12
Is there a way to within a query to use a date calculation to do the following rather than having to do it with php

select * from table
where DATE >=  '2011-09-17' (todays date)
AND DATE <=  '2011-09-24'  (one week from now)
0
Comment
Question by:PeterErhard
5 Comments
 

Expert Comment

by:savsoft
ID: 36553248
just use data type as date for date column then use simple query as mention .. It will work fine
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 36553259
If I'm understanding correctly, you can use mySQL's date functions to calculate the dates.

SELECT *
FROM     table
WHERE  DATE >= curDate()
AND       DATE <=  DATE_ADD(curDate(), INTERVAL 7 DAY)
0
 

Expert Comment

by:savsoft
ID: 36553262
yes but use datatype as date for date column field
0
 
LVL 16

Expert Comment

by:Swadhin Ray
ID: 36553268
Try this:

mysql> select * from table where date_column between  '2011-09-17'and  '2011-09-24';

mysql> Select * from tables where date > "2011-09-17' and CREATE_TIME < "2011-09-24";

0
 

Author Comment

by:PeterErhard
ID: 36553929
Thanks for your help guys, _agx_'s was what I was most looking for.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question