Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Date within mySQL query

Posted on 2011-09-16
5
Medium Priority
?
329 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

730 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