Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-08-2006, 11:15 PM   PM User | #1
JanObe
New Coder

 
Join Date: Jun 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
JanObe is an unknown quantity at this point
Date format issue

Hi, well my boss said the format for the date in our database is mm/dd/yyyy and when i get the current_date() to compare the two I have the problem of them being different

current_date() is yyyy-mm-dd (right?)
event_startDate is mm-dd-yyyy

I tried using the get_format() function to get them to be the same but it doesnt seem to be working correctly.

What I am trying to do is write a query that gets the information for the next upcoming meeting. Thus, the events_startDates needs to be greater than the current_date() and i merely grab the "closest" meeting or the first row as it were.

This is what i have so far. How do I get the dates to be comparable to each other?

$query = mysql_query("SELECT * FROM meeting_list, events WHERE event_startDate > current_date() AND eventID = ID AND event_type != 'Sales' ORDER BY event_dates ASC LIMIT 1");
JanObe is offline   Reply With Quote
Old 08-08-2006, 11:41 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
You should always store dates using a data type of "date". Find out if this is the case.

If your event_startDate is being stored as a string, you'll need to use the str_to_date() function on it to transform it into a date before you can use comparison operators on it.
Fumigator is offline   Reply With Quote
Old 08-08-2006, 11:55 PM   PM User | #3
JanObe
New Coder

 
Join Date: Jun 2006
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
JanObe is an unknown quantity at this point
lol...yeah he just got off the phone and told me it is a string. He thinks the best way to handle this is to split the string up and compare each part.

personally, I dont know what would be best or easiest but whatever i choose it is only temporary. He plans on changing the column to date soon.

bah, this is silly
JanObe is offline   Reply With Quote
Old 08-09-2006, 12:05 AM   PM User | #4
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Splitting up the string and comparing each part would be the absolute worst way to do it... try str_to_date() first.
Fumigator is offline   Reply With Quote
Old 08-09-2006, 02:27 AM   PM User | #5
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
See the link in my signature about varchar dates.
guelphdad is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:32 PM.


Advertisement
Log in to turn off these ads.