General
cancel
Showing results for 
Search instead for 
Did you mean: 

required info on timestamp in shell script

Karthik_sg
Frequent Advisor

required info on timestamp in shell script

hi all,
I have a field named timestamp in a tablei n mysql database.And its datatype is timestamp.for ex: the values in that field will look like, 2007-07-02 17:26:06

My question is this:i am accepting only date in my shell script as input.So do we need to enter the seconds also or just date will do.
If only date is the input how to check all the entries for that give date(since hours,mins and seconds changes rit).Pls do reply asap.Thnks in advance.
4 REPLIES
Stuart Browne
Honored Contributor

Re: required info on timestamp in shell script

A 'timestamp' field will quite happily just take a date. It will assume midnight of that day however.
One long-haired git at your service...
Karthik_sg
Frequent Advisor

Re: required info on timestamp in shell script

k.But it is incorrect rit.Because if it takes the midnight time,wht about the other time in the same day.So if i do a select * from table where date=27-01-2007 it wil just return one value.i.e, midnight time.The rest will be ignored.So how to go abt it.any other suggestions
Stuart Browne
Honored Contributor

Re: required info on timestamp in shell script

Oh. You want to retrieve data from the field..

Compare it against a date_format() that just looks at the month:

SELECT * FROM tbl WHERE DATE_FORMAT(timestamp_field, "%Y-%m-%d") = '2007-01-27';

You can manipulate the date order to be however you want at this point.
One long-haired git at your service...
Karthik_sg
Frequent Advisor

Re: required info on timestamp in shell script

k.Thnks,I wil let u know whtr it works or not.