View unanswered posts | View active topics
It is currently Thu May 15, 2025 2:17 pm
|
Page 1 of 1
|
[ 10 posts ] |
|
Author |
Message |
tombolt
Spends far too much time on here
Joined: Fri Apr 24, 2009 8:38 am Posts: 2967 Location: Dorchester, Dorset
|
Hi all, I've got a database for my job list and it works a treat, however, I want to change the format of the date column. I currently have: I know I need to use the DATE_FORMAT() somehow as: The trouble is, I don't know where to put it. If I put it as part of the search query, it doesn't work, nor does it work if I do it separately.
|
Mon Jan 10, 2011 1:43 pm |
|
 |
tombolt
Spends far too much time on here
Joined: Fri Apr 24, 2009 8:38 am Posts: 2967 Location: Dorchester, Dorset
|
Well, I've done it in PHP by using the following: I'd still like to know how to make MySql do the work if anyone knows how though.
|
Mon Jan 10, 2011 3:31 pm |
|
 |
tombolt
Spends far too much time on here
Joined: Fri Apr 24, 2009 8:38 am Posts: 2967 Location: Dorchester, Dorset
|
Had the whole thing working a treat on MAMP, so installed it on my ISP's server and it mostly works. However, I get the following error when trying to update a record: The code I'm using is: I really can't see anything wrong in that and it worked fine on MAMP. MySql version 5.1 on my ISP, not sure what MAMP is on at the moment as I'm at home and it's at work.
|
Mon Jan 10, 2011 7:27 pm |
|
 |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
The main problem I've had from jumping from MAMP to Apache is capitalisation issues, MAMP seems somewhat lax about capitalisation whereas Apache is really strict. Might be work checking variable names, etc.
|
Mon Jan 10, 2011 10:02 pm |
|
 |
tombolt
Spends far too much time on here
Joined: Fri Apr 24, 2009 8:38 am Posts: 2967 Location: Dorchester, Dorset
|
I might just do that, I've already had on capitalisation issue, but that was just a simple URL.
|
Mon Jan 10, 2011 10:56 pm |
|
 |
tombolt
Spends far too much time on here
Joined: Fri Apr 24, 2009 8:38 am Posts: 2967 Location: Dorchester, Dorset
|
Well, tried it at work this morning and seems to be running fine. Don't know what all that was about.
|
Tue Jan 11, 2011 9:53 am |
|
 |
big_D
What's a life?
Joined: Thu Apr 23, 2009 8:25 pm Posts: 10691 Location: Bramsche
|
The SELECT DATE_FORMAT('Date', '%d/%m/%Y') works as follows:
SELECT col1, col2, col3, DATE_FORMAT(col4, '%d/%m/%Y) as myDate FROM ...
_________________ "Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari
Executive Producer No Agenda Show 246
|
Wed Jan 12, 2011 4:40 am |
|
 |
tombolt
Spends far too much time on here
Joined: Fri Apr 24, 2009 8:38 am Posts: 2967 Location: Dorchester, Dorset
|
Aah, thanks Dave, so I can't do a select all, have to enter each column and specify which one to format. Thanks, makes sense.
|
Wed Jan 12, 2011 11:24 am |
|
 |
big_D
What's a life?
Joined: Thu Apr 23, 2009 8:25 pm Posts: 10691 Location: Bramsche
|
Yep. Although I think mysql drops the "as" (SQL Server and Oracle use AS, I believe, the small changes always confuse me and I haven't done any SQL for a while), so it would be SELECT FORMAT_DATE(...) myDate FROM ...
_________________ "Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari
Executive Producer No Agenda Show 246
|
Thu Jan 13, 2011 4:30 am |
|
 |
tombolt
Spends far too much time on here
Joined: Fri Apr 24, 2009 8:38 am Posts: 2967 Location: Dorchester, Dorset
|
Cool thanks.
|
Thu Jan 13, 2011 1:12 pm |
|
|
|
Page 1 of 1
|
[ 10 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 3 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum
|
|