newbie
newbie

Reputation: 1980

MYSQL selecting date on timestamp

I know this question have many similar posts but I'm having a hard time finding what I truly need.

I want to get only date from timestamp which I got the answer here. I tried that using the query below:

SELECT *, DATE('2014-04-26') FROM labor

Code above is working perfectly fine. But I want to know how do I get all records including there timestamp but only extracting the date from the timestamp

If I'm using a wrong datatype please let me know. My table structure is like this:

enter image description here

Thank you in advance.

Upvotes: 3

Views: 257

Answers (3)

Sadikhasan
Sadikhasan

Reputation: 18600

Try this

SELECT *, DATE(last_update) FROM labor;

Upvotes: 2

Tomas Pastircak
Tomas Pastircak

Reputation: 2857

You'll need

SELECT *, DATE(FROM_UNIXTIME(last_update) FROM labor

See also this question detailing timestamp conversions.

Upvotes: 2

Abhik Chakraborty
Abhik Chakraborty

Reputation: 44844

You can do as

select 
    col1,
    col2,
    ...
    coln,
    date(last_update)
    from labor

col1. col2..coln are the column names from your table except the last_update.

Upvotes: 1

Related Questions