December 22, 2015 at 12:42 am
Hi,
I am very new to SQL and learning as I go. I am creating some very basic php pages that gather and display data from an SQL server. I am having trouble formatting the dates though.
I would like my date to be in the format of DD/MM/YY with no time stamps. They currently show as MM/DD/YYY HH:MM:SS
My code is:
While ($row = mysql_fetch_array($result)) {
exho "<b>Supplier: " .$row{'Supplier_Name'}. "
Start Date: </b>" .$row{'Start_Date}."
"; }
Thanks
December 23, 2015 at 3:46 am
You might be better asking this question on a PHP forum.
Are you using MS SQL Server or MySQL?
If you are using MS SQL Server then the following will convert a date into UK format (dd/mm/yyyy) but I doubt it will work if you put it into the code you posted - you might have to go back to where you are initially populating the array and amend this query.
convert(varchar(10),Start_Date,103) as Start_Date
December 23, 2015 at 10:09 pm
try the below query to get result in DD/MM/YY format.
select LEFT(convert(varchar(10), @date, 103),6) + Right(Year(@date)+ 1,2)
December 24, 2015 at 3:16 pm
johnwalker10 (12/23/2015)
try the below query to get result in DD/MM/YY format.
select LEFT(convert(varchar(10), @date, 103),6) + Right(Year(@date)+ 1,2)
Gosh, no... Never do date/time formatting for a GUI from SQL Server. Let the GUI do the formatting so that local datetime settings can prevail. As previously suggested on this thread, a PHP forum would be the best place to discover how to do this.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply