Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2007-05-07, 08:47 PM
Junior Member
 
Join Date: May 2007
Posts: 2
Charliezak is on a distinguished road
Default Mysql Date Format

Hi, im trying to get a date range Between anydate to anydate,

my date format is dd.mm.yyyy


this is the table

CREATE TABLE table (
id int(11) unsigned NOT NULL auto_increment,
custid varchar(11) NOT NULL default '',
note text NOT NULL,
date varchar(10) NOT NULL default '',
datefu varchar(10) NOT NULL default '',
PRIMARY KEY (id)
) TYPE = MyISAM;

is it basicly
SELECT * FROM $tablename WHERE datefu BETWEEN DATE $datefa AND DATE $datefb

Last edited by Charliezak; 2007-05-07 at 08:52 PM.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2007-05-08, 12:14 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

What is the error you get?

I never use date formats, always use timestamps since they are so much easier to deal with.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #3 (permalink)  
Old 2007-05-08, 12:20 AM
Junior Member
 
Join Date: May 2007
Posts: 2
Charliezak is on a distinguished road
Default

Thanks For the quick reply,

um its not really and error to my understanding MySQL dosnt not like to search ranges by this date format dd.mm.yyyy

i have so far converted dd.mm.yyyy to yyyy-mm-dd

by

Code:
SELECT STR_TO_DATE(DATE,'%d/%m/%Y') as Mydate from table1;
But now i want to range it Say SELECT * FROM table1 WHERE Mydate BETWEEN $daterange1 AND $daterange2

so it only select the dates in that range

I have changed it to

Code:
 select custid, date, str_to_date(date,'%d.%m.%Y') as datefu from custnotes WHERE datefu BETWEEN DATE '2007-03-01' AND DATE '2007-05-30';
but it says there are 0 entrys

am i doing somthing wrong ??

Last edited by Charliezak; 2007-05-08 at 07:07 PM.
Reply With Quote
  #4 (permalink)  
Old 2007-10-22, 04:53 AM
Junior Member
 
Join Date: Oct 2007
Posts: 23
celon_php_master is on a distinguished road
Default

use timestamp in the table format
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:08 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.