3

Iam getting the date and time from Database as follows

Date : 20100101(YYYY/MM/DD) Time : 120912 (HH:MM:SS)

I have to format the Date as follows 20100101 --> (2010-10-11) (look to have ) "-" in between year and month and Day

I have to format the time as follows 120912 --> 12:02:12 suppose I may have the time as 62367 from the database

06:23:67

1
  • what database you're using? I've never heard of DBMS called "Database" Sep 3, 2010 at 7:14

2 Answers 2

1

I recommend you convert the data using: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

1
  • I think it's easier to do this in PHP than in SQL
    – Mischa
    Sep 3, 2010 at 3:21
0

we can use DATE_FORMAT(fieldname,format ) function in mysql For Example we can use DATE_FORMAT( a.date, '%d-%m-%Y' )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.