Register FAQ Members List Calendar Arcade Search Today's Posts Mark Forums Read

Go Back   2 dark Park Forum > The Other Forums > Hardware/Software Chat
Reply
 
Thread Tools Display Modes
MikeJComputer
AFKA Hawk/JMU1337
 
MikeJComputer's Avatar
 

Join Date: Jan 2002
Posts: 6,414
Level: 56
HP: 557 / 1379
MP: 2138 / 34965
EXP: 18%
SQL help?

Just something for my website... Don't care if I never get it to work... been using it as-is for 4 years

I have a database of entries that I want to order by date. I've been ordering them by date simply by putting them into the database in order and sort on their uin. I have a date field, but it's stored as a varchar in mm/dd/yy format. I would like to sort records on that instead so if I forget to put an entry in, I don't have to backtrack to have it get placed in the right place.

My current query:

$sqldata = "SELECT * FROM ".$db_prefix."entry ORDER BY `uin` DESC";

I've done 5 minutes of messing around with date and type conversion crap, but to no avail. It's not worth me putting in any more time than that, but if any of y'all are SQL gurus, I'm sure you'll have an answer in seconds.

The output: http://www.iammike.org/index.php?loc=log
__________________
I Am Mike | Madison Motorsports
Old 07-30-2010, 04:34 PM #1
Reply With Quote
MikeJComputer is offline  
RIP
Hey!
 
RIP's Avatar
 

Join Date: Jul 2002
Location: o
Posts: 12,784
Level: 70
HP: 1489 / 1731
MP: 4261 / 41144
EXP: 25%
Quote:
Originally Posted by MikeJComputer View Post
I have a date field, but it's stored as a varchar in mm/dd/yy format.
Haven't done a whole lot of SQL, but enough to know that this is bad times. Why not convert your field into the date type? It's the Right Thing to do...
__________________
Jak: 12 years gone by as if it was yesterday. Not long ago i came to the US barely able to put together a short sentence. Now i can put together one full sentence.
Old 07-30-2010, 05:05 PM #2
Reply With Quote
RIP is offline  
Kleptosis
Soon I'll b racin forealz
 
Kleptosis's Avatar
 

Join Date: May 2005
Location: NoVA
Posts: 7,029
Level: 57
HP: 1033 / 1423
MP: 2343 / 22024
EXP: 92%
Have you tried using order by in conjunction with convert?
__________________
Before you talk shit about someone, you should walk a mile in his shoes. That way, when you talk shit about him, you're a mile away and you have his shoes.
Old 07-30-2010, 07:01 PM #3
Reply With Quote
Kleptosis is online now  
rdg
I have a big chin
 
rdg's Avatar
 

Join Date: Oct 2004
Location: dc-ish
Posts: 5,910
Level: 54
HP: 732 / 1341
MP: 1970 / 23192
EXP: 65%
google "mysql str_to_date"


if you can't set it to default "10" to "2010" for the year.. then adjust the string date to 2010 and then run str_to_date.. you could even do that on the fly in a subquery.
__________________
Quote:
Originally Posted by peonmyhall
I see what you did there steve and you looked cool doing it.
Old 07-30-2010, 07:02 PM #4
Reply With Quote
rdg is offline  
MikeJComputer
AFKA Hawk/JMU1337
 
MikeJComputer's Avatar
 

Join Date: Jan 2002
Posts: 6,414
Level: 56
HP: 557 / 1379
MP: 2138 / 34965
EXP: 18%
Quote:
Originally Posted by Kleptosis View Post
Have you tried using order by in conjunction with convert?
yes.


AutoMerged DoublePost


Quote:
Originally Posted by RIP View Post
Haven't done a whole lot of SQL, but enough to know that this is bad times. Why not convert your field into the date type? It's the Right Thing to do...
would require the rewrite of some code, which would take more than 5 minutes, but not likely more than 20. still, too long.


AutoMerged DoublePost


Quote:
Originally Posted by rdg View Post
google "mysql str_to_date"


if you can't set it to default "10" to "2010" for the year.. then adjust the string date to 2010 and then run str_to_date.. you could even do that on the fly in a subquery.
will look into this.
__________________
I Am Mike | Madison Motorsports

Last edited by MikeJComputer : 07-30-2010 at 09:32 PM. Reason: Automerged Doublepost
Old 07-30-2010, 09:31 PM #5
Reply With Quote
MikeJComputer is offline  
Kleptosis
Soon I'll b racin forealz
 
Kleptosis's Avatar
 

Join Date: May 2005
Location: NoVA
Posts: 7,029
Level: 57
HP: 1033 / 1423
MP: 2343 / 22024
EXP: 92%
Quote:
Originally Posted by RIP View Post
Haven't done a whole lot of SQL, but enough to know that this is bad times. Why not convert your field into the date type? It's the Right Thing to do...
Yes, obviously that's the right thing to do. He's trying to get us to find a shortcut for him, though.
__________________
Before you talk shit about someone, you should walk a mile in his shoes. That way, when you talk shit about him, you're a mile away and you have his shoes.
Old 07-30-2010, 10:11 PM #6
Reply With Quote
Kleptosis is online now  
rdg
I have a big chin
 
rdg's Avatar
 

Join Date: Oct 2004
Location: dc-ish
Posts: 5,910
Level: 54
HP: 732 / 1341
MP: 1970 / 23192
EXP: 65%
Quote:
Originally Posted by Kleptosis View Post
Yes, obviously that's the right thing to do. He's trying to get us to find a shortcut for him, though.
haha. indeed he's looking for us to paste in a sql query for him to run.. and I really want to just to commit to memory how to do it but i refuse to assist mike

(because I'm in another country)
__________________
Quote:
Originally Posted by peonmyhall
I see what you did there steve and you looked cool doing it.
Old 07-30-2010, 10:52 PM #7
Reply With Quote
rdg is offline  
MikeJComputer
AFKA Hawk/JMU1337
 
MikeJComputer's Avatar
 

Join Date: Jan 2002
Posts: 6,414
Level: 56
HP: 557 / 1379
MP: 2138 / 34965
EXP: 18%
Quote:
Originally Posted by Kleptosis View Post
Yes, obviously that's the right thing to do. He's trying to get us to find a shortcut for him, though.
Is this what you looked like when you told that driver how it was?

__________________
I Am Mike | Madison Motorsports
Old 07-30-2010, 11:47 PM #8
Reply With Quote
MikeJComputer is offline  
RIP
Hey!
 
RIP's Avatar
 

Join Date: Jul 2002
Location: o
Posts: 12,784
Level: 70
HP: 1489 / 1731
MP: 4261 / 41144
EXP: 25%
Quote:
Originally Posted by Kleptosis View Post
Yes, obviously that's the right thing to do. He's trying to get us to find a shortcut for him, though.
And, as I would predict, in looking for the shortcut, he is probably spending more time than it would take to fix the problem the right way. Obviously it's the right thing to do - often when I code and am looking for shortcuts, I just need to be told by someone to do the obvious thing. Also, if he doesn't actually fix the real problem, then a year from now when he wants to do something else, he'll have to come up with another workaround. I was just trying to help by suggesting that he bite the bullet, get 20 fewer minutes of sleep, and fix the problem the most effective way. If you don't care for this explanation, you may kindly lick my buttocks
__________________
Jak: 12 years gone by as if it was yesterday. Not long ago i came to the US barely able to put together a short sentence. Now i can put together one full sentence.
Old 07-31-2010, 12:51 AM #9
Reply With Quote
RIP is offline  
Araemo
Pak Chooie Unf
 
Araemo's Avatar
 

Join Date: Nov 2003
Location: .
Posts: 9,319
Level: 63
HP: 1175 / 1563
MP: 3106 / 30999
EXP: 54%
Quote:
Originally Posted by rdg View Post
haha. indeed he's looking for us to paste in a sql query for him to run.. and I really want to just to commit to memory how to do it but i refuse to assist mike

(because I'm in another country)
Pft. What country? Canadia?
__________________
I shove around the blind people.
Old 07-31-2010, 12:59 AM #10
Reply With Quote
Araemo is offline  
MikeJComputer
AFKA Hawk/JMU1337
 
MikeJComputer's Avatar
 

Join Date: Jan 2002
Posts: 6,414
Level: 56
HP: 557 / 1379
MP: 2138 / 34965
EXP: 18%
Quote:
Originally Posted by RIP View Post
And, as I would predict, in looking for the shortcut, he is probably spending more time than it would take to fix the problem the right way. Obviously it's the right thing to do - often when I code and am looking for shortcuts, I just need to be told by someone to do the obvious thing. Also, if he doesn't actually fix the real problem, then a year from now when he wants to do something else, he'll have to come up with another workaround. I was just trying to help by suggesting that he bite the bullet, get 20 fewer minutes of sleep, and fix the problem the most effective way. If you don't care for this explanation, you may kindly lick my buttocks
I thought I already made it clear that this is not worth 20 minutes of my time. If you don't know a "shortcut," kindly STFU.
__________________
I Am Mike | Madison Motorsports
Old 07-31-2010, 05:01 PM #11
Reply With Quote
MikeJComputer is offline  
Kleptosis
Soon I'll b racin forealz
 
Kleptosis's Avatar
 

Join Date: May 2005
Location: NoVA
Posts: 7,029
Level: 57
HP: 1033 / 1423
MP: 2343 / 22024
EXP: 92%
You all are forgetting how important Mike is and how much each minute of his time is actually worth. If you only knew...
__________________
Before you talk shit about someone, you should walk a mile in his shoes. That way, when you talk shit about him, you're a mile away and you have his shoes.
Old 07-31-2010, 05:34 PM #12
Reply With Quote
Kleptosis is online now  
MikeJComputer
AFKA Hawk/JMU1337
 
MikeJComputer's Avatar
 

Join Date: Jan 2002
Posts: 6,414
Level: 56
HP: 557 / 1379
MP: 2138 / 34965
EXP: 18%
Quote:
Originally Posted by Kleptosis View Post
You all are forgetting how important Mike is and how much each minute of his time is actually worth. If you only knew...
GOD DAMN! Good one!
__________________
I Am Mike | Madison Motorsports
Old 07-31-2010, 06:18 PM #13
Reply With Quote
MikeJComputer is offline  
RIP
Hey!
 
RIP's Avatar
 

Join Date: Jul 2002
Location: o
Posts: 12,784
Level: 70
HP: 1489 / 1731
MP: 4261 / 41144
EXP: 25%
Quote:
Originally Posted by MikeJComputer View Post
I thought I already made it clear that this is not worth 20 minutes of my time.
And how much time would you say you've spent so far on these TPS reports?

__________________
Jak: 12 years gone by as if it was yesterday. Not long ago i came to the US barely able to put together a short sentence. Now i can put together one full sentence.
Old 07-31-2010, 10:39 PM #14
Reply With Quote
RIP is offline  
Mortal_Wombat
banned
 
Mortal_Wombat's Avatar
 

Join Date: Feb 2002
Location: Greenville, SC
Posts: 11,161
Level: 67
HP: 1180 / 1657
MP: 3720 / 41598
EXP: 31%
fucking lol.
__________________
Quote:
Originally Posted by asparagus View Post
Yeah, everyone knows its no fun when you accidentally cockslap yourself in the nuts so hard you fall over.
(╬ಠ益ಠ)
Old 07-31-2010, 11:31 PM #15
Reply With Quote
Mortal_Wombat is offline  
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Contains New Posts New Posts Contains No New Posts No New Posts A Closed Forum Closed Forum
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Powered by vBadvanced CMPS v1.0.0