Jump to content


Photo

Problem with getting records between two dates


  • Please log in to reply
3 replies to this topic

#1 jbpunjabi

jbpunjabi
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 04 June 2003 - 10:30 PM

Select
item_id,
customer_name,
DATE_FORMAT(picked_up_date,\'%D %M, %Y\' pickedUp_date
from
jb_inventory
where
(picked_up_date >=1/3/2002 and picked_up_date<=6/3/2003)
and
is_picked_up=\'Y\'
order by
ticket_id

I am trying to get al the records between 1/3/2002 and 6/3/2003. But this query is giving me nothing and if I change the \'and\' to \'or\' then it gives me all the records..

any help !!!!!
Jbpunjabi

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 04 June 2003 - 10:53 PM

does the database use the same date format that you are using in your query? you may try quoting the info or using BETWEEN.

http://www.mysql.com..._Operators.html
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 jbpunjabi

jbpunjabi
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 04 June 2003 - 10:58 PM

Actualy I even tried using the dateformat cos the format in database is diff from the format in quert, but still its same result..but I havent tried the between..let me try that
Jbpunjabi

#4 jbpunjabi

jbpunjabi
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 05 June 2003 - 03:54 AM

I worked, I put the date in quotes and used the date format function to change the database date

Select
item_id,
customer_name
from
jb_inventory
where
(DATE_FORMAT(picked_up_date,\'%c/%e/%Y\') >=\'1/9/2002\'
and
DATE_FORMAT(picked_up_date,\'%c/%e/%Y\') <=\'6/4/2003\')
and
is_picked_up=\'Y\'
order by
ticket_id

Thanks effigy
Jbpunjabi




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users