query for timestamp

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
nhan
Forum Commoner
Posts: 95
Joined: Sun Feb 27, 2005 8:26 pm
Contact:

query for timestamp

Post by nhan »

how can i query for selecting timestamp? example my timestamp field is :
20050309145502

how can i search for the specific date only if my query is the exact date traditionally my syntax is :
select * from timein where timestamp = 20050309145502;

i have to select the first 8 digits only... can anyone help me....

thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I already told you how to do this in the other thread. :|
User avatar
nhan
Forum Commoner
Posts: 95
Joined: Sun Feb 27, 2005 8:26 pm
Contact:

query for timestamp

Post by nhan »

thanks feyd, im sorry for these stupid questions...
i tried this one but it doesnt display the record, i really dont know the term its called, but i have d idea in my mind....

i just want to query all records having the date only... the timestamps include the time, so when i query the results are zero...

select * from tbl where timestamp = 'date_format(20050309)';

thanks so much!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you'll need date_format() on the timestamp, not the input date you are trying against (provided you supply in a form that is compatible with the date_format() output... You may want to research how date_format() works.. http://dev.mysql.com/doc/mysql/en/date- ... tions.html
User avatar
nhan
Forum Commoner
Posts: 95
Joined: Sun Feb 27, 2005 8:26 pm
Contact:

Post by nhan »

thanks so much sir feyd!

i saw some link on the internet and this is also possible solution for my problem....

:)

select * from tbl where data3 like '03-09-05%';

i never thought that using "like" would be possible... thanks for your help!

regards,

nhan
Post Reply