[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Filter by data and current_date

Posted on 2016-10-17
4
Medium Priority
?
64 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 59

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 59

Expert Comment

by:Julian Hansen
ID: 41848271
You are welcome.
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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
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

650 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