Solved

Date within mySQL query

Posted on 2011-09-16
5
323 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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel - SQL export question 3 58
Upgrade MySQL 5.5 to MySQL 5.6 on Windows 13 122
MySQL programmer starter 25 66
emailing registered email addresses in phpmyadmin 5 71
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 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