Solved

Filter by data and current_date

Posted on 2016-10-17
4
38 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
  • 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 52

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 52

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

912 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now