By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,263 Members | 1,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,263 IT Pros & Developers. It's quick & easy.

How to display a date stored in a table with the desired way?

mikek12004
100+
P: 200
I have a table where I store dates in smalldatetime format like this '2008-07-28 14:47:00' I want in PHP to retrieve these values and display them like '28/07/08' I retrieved the dates from the table and inside the first loop I put

Expand|Select|Wrap|Line Numbers
  1. $qdate=mssql_query("select CONVERT(varchar(20), '$rcrit[5]', 103)");    
  2.  
where $rcrit[5] the variable holding the date, saddly it didnot work I tried in MSSQL to put
Expand|Select|Wrap|Line Numbers
  1. CONVERT(varchar(20),'2008-07-28 14:47:00' ,104)
but still it does not show the desired format any ideas?
Sep 16 '08 #1
Share this Question
Share on Google+
3 Replies


code green
Expert 100+
P: 1,726
"It did not work" is not very helpful. What did you get?
The PHP syntax looks like it will fail to me.
Was there an error?
Sep 16 '08 #2

ck9663
Expert 2.5K+
P: 2,878
Since you're looping through the result set, can't PHP handle it rather than SQL Server?

-- CK
Sep 16 '08 #3

iburyak
Expert 100+
P: 1,017
Try this:


Expand|Select|Wrap|Line Numbers
  1. select CONVERT(varchar(20),convert(datetime, '2008-07-28 14:47:00') ,103)
Good Luck.
Sep 16 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.