tags:

views:

33

answers:

1

I have created a timestamp field in mysql, where the date gets stored as 06/01/2010 07:55:40

Now if I try to search anything using a query like this :

select StartTime 
  from results 
 where timestamp(StartTime) = "30/09/2009"

it does not work.

even I cannot use this :

select * 
  from results 
  where StartTime between "06/01/2010 07:55:40" and "01/02/2010 07:55:40"

If I use:

select  timestamp(current_date());

...then it shows 02/03/2010 00:00:00

Should I change the format to something like 00-00-0000 ? Or can I search using the same format that is currently in the table?

Can anyone suggest please?

A: 

Use explicit format:

SELECT  *
FROM    results
WHERE   starttime = TIMESTAMP(STR_TO_DATE('02/03/2010 21:30:00', '%d/%m/%Y %H:%i:%s'));
Quassnoi
insted of using this everytime, will it be easy to convert my timestamp in my database?
JPro
@JPro: convert to what?
Quassnoi