0

How do I change the format of date + time in a database when calling it?

Currently it's:

YYYY-MM-DD Days:HH:MM 

But I need it to be:

DD-MM-YYYY Days:HH:MM 

I tried this approach

FORMAT(s.date, 'DD-MM-YYYY') 

But it gives me something like this:

20,130,618,232,643 

Because it has time included I think.

4
  • Which DBMS are you using? Postgres? Oracle? And which SQL client to display the data? Commented Jun 20, 2013 at 11:47
  • MySQL and I call it with PHP Commented Jun 20, 2013 at 11:50
  • 1
    what is the type of s.date Commented Jun 20, 2013 at 11:51
  • It's DATETIME in this format 2013-06-18 23:26:43 I want it to be 18-06-2013 23:26:43 instead Commented Jun 20, 2013 at 11:53

1 Answer 1

1

Use DATE_FORMAT(date, format):

DATE_FORMAT(s.date,'%d-%m-%Y') 
Sign up to request clarification or add additional context in comments.

Comments