The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

But When I use this timestamp to query the data from table,
Due to the seconds mistach the first value is missed out.
So how can i avoid it using the query excluding the seconds
If i use timestamp as 2008-08-07 12:20 then last value is missed out. It is considered as 2008-08-07 12:20:00

select timestamp, fieldname from table where timestamp <= ('".$time."') and timestamp >= date_sub('".$time."',interval 1 day) group by timestamp order by timestamp.

You could try working from something like this which will trim the characters off the tail of the string - 1 is the starting point & 16 is the amount of characters to include in the string. You should be able to customise this to work so you're basically ignoring the seconds.

SELECT TOP (10)
SUBSTRING(timestamp, 1, 16) AS TimestampTrimmed
FROM yourtable

Actually if I use date(timestamp)=date(now()) is for matching the date and current date. In similar way how to match only the format YYYY-mm-dd hr:min
and not seconds.

If I use the query as below
SELECT timestamp from tablename where substring(timestamp,1,16) <= ('2008-08-18 11:20') and substring(timestamp,1,16) >= date_sub('2008-08-18 11:20',interval 1 day) group by timestamp order by timestamp;

The output doesnot fetch the previous day's data at timestamp 2008-08-18 11:20 even if it present.