Solved

Filter by data and current_date

Posted on 2016-10-17
4
56 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 250 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 57

Accepted Solution

by:
Julian Hansen earned 250 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 57

Expert Comment

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

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can i make performance tuning to my sql query? 6 69
category table 2 41
Generate PDF from MySQL using PHP 3 68
How efficient to move databases to Azure? 5 83
Foreword This article was written many years ago, in the days when PHP supported the MySQL extension (http://php.net/manual/en/function.mysql-connect.php).  Today (http://php.net/manual/en/migration70.removed-exts-sapis.php) you would not use MySQL…
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 …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 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