Jump to content

how to get and convert


mga_ka_php

Recommended Posts

is it possible that i could get and convert the content of a column.

 

example.

id        message

1        have a message for you last 12993234

 

the 12993234 is a timestamp for example.

 

i want to have a sql statement that will get that timestamp and convert it to a date

 

example: SELECT id, message, (statement here) AS date FROM table1

 

id    message                                              date

1    have a message for you last 12993234      2009-02-16

 

12993234  --->  2009-02-16

 

the timestamp was converted to a date format of yyyy-mm-dd

 

is that possible? if possible how do i do that?

Link to comment
Share on other sites

DATE_FORMAT

 

 

 

And you will need to convert the unix timestamp to DATETIME first.

 

 

So something like:

 

DATE_FORMAT('%Y-%m-%d',  FROM_UNIXTIME(column_name));

 

 

 

 

I think that DATE might be in that format, so you might just be able to convert it to a date.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.