3

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.

Community
  • 1
  • 1
newbie
  • 1,884
  • 7
  • 34
  • 55

3 Answers3

2

Try this

SELECT *, DATE(last_update) FROM labor;
Sadikhasan
  • 18,365
  • 21
  • 80
  • 122
2

You'll need

SELECT *, DATE(FROM_UNIXTIME(last_update) FROM labor

See also this question detailing timestamp conversions.

Community
  • 1
  • 1
Tomas Pastircak
  • 2,867
  • 16
  • 28
  • What is the difference of this from `SELECT *, DATE('last_update') FROM labor;`? – newbie Apr 26 '14 at 13:12
  • @newbie appears that there is no real difference - I was not aware that it is possible to call DATE with giving a timestamp. The other answers are definitely better. – Tomas Pastircak Apr 26 '14 at 13:15
1

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.

Abhik Chakraborty
  • 44,654
  • 6
  • 52
  • 63