Forum Moderators: coopster
here is what I want to query.
IP_address and Timestamp > these are two tables that I am to be queried when displaying results. Below is a sample of how the database columns look like.
ip_address Timestamp
192.168.1.1 2006-01-23 10:07:35
Sample query that works when both date and time are entered.
select timestamp, signature from acid_event where timestamp = '2006-01-22 12:14:59'
How do I run this same query but without entering the second part (time)
I can run a query for the ip address just fine. The problem is that I want to be able to query for both the IP address and the Timestamp. My question is how to I query the timestamp column just by using the 2006-01-23 and leaving out the time. So just make sure I am being clear if I wanted to do a query for anything that happened on 2006-01-23 from 192.168.1.1 how would I go about that?
thanks for the help in advance.
SELECT timestamp, signature FROM acid_event WHERE DATE_FORMAT(timestamp, '%Y-%c-%d') = '2006-01-22'
-sned
see the mysql manual [dev.mysql.com] on date and time functions
--
-- c = Month, numeric (0..12)
-- m = Month, numeric (00..12)
--
SELECT timestamp, signature FROM acid_event WHERE DATE_FORMAT(timestamp, '%Y-%m-%d') = '2006-01-22'
SUBSTRING would work as well, but it would start at position 1:
WHERE substring(timestamp,1,10) = '2006-01-22'