?
Solved

Filter by data and current_date

Posted on 2016-10-17
4
Medium Priority
?
59 Views
Last Modified: 2016-10-18
Hello Guys

I have a field in my table that keeps date and time, but I need to filter the field only by current_date, how can I do that?

SELECT * FROM TABLE A
WHERE A.DATA=CURRENT_DATE

Something like my example
thanks
0
Comment
Question by:hidrau
[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
  • 2
4 Comments
 
LVL 22

Assisted Solution

by:Kim Walker
Kim Walker earned 1000 total points
ID: 41847593
I have a field in my table that keeps date and time
Your field has both date and time? But you want to filter on date only, correct? Try:
SELECT * FROM TABLE A
WHERE DATE(A.DATA)=CURRENT_DATE

Open in new window

1
 
LVL 58

Accepted Solution

by:
Julian Hansen earned 1000 total points
ID: 41847761
Is TABLE the name of your table? TABLE is a reserved word so you should back tick it if you are using it as a name

The current date is returned by the function NOW()

To ensure you are comparing only the Date parts of potential date/time fields use the DATE() function to only return the date elements.

SELECT * FROM `TABLE` A WHERE DATE(A.date) = DATE(NOW());

Open in new window

1
 
LVL 1

Author Closing Comment

by:hidrau
ID: 41848161
thanks a lot
0
 
LVL 58

Expert Comment

by:Julian Hansen
ID: 41848271
You are welcome.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
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

770 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