URGENT HELP NEEDED PLEASE! Selecting a date range without the year

This is a discussion on URGENT HELP NEEDED PLEASE! Selecting a date range without the year within the MySQL Database forums, part of the Database Forums category; Hi, I need to be able to select a range of dates between cretain months and days but without the ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-22-2007
macca
 
Posts: n/a
Default URGENT HELP NEEDED PLEASE! Selecting a date range without the year

Hi,
I need to be able to select a range of dates between cretain months
and days but without the year,

Something like :

SELECT foobar FROM footable WHERE dates BETWEEN start_date_month_day
AND end_date_month_day


That will return all the results between those months and days
regardless of the year.


Any help would be appreciated.

Thanks, paul.

Reply With Quote
  #2 (permalink)  
Old 04-22-2007
Paul Lautman
 
Posts: n/a
Default Re: URGENT HELP NEEDED PLEASE! Selecting a date range without the year

macca wrote:
> Hi,
> I need to be able to select a range of dates between cretain months
> and days but without the year,
>
> Something like :
>
> SELECT foobar FROM footable WHERE dates BETWEEN start_date_month_day
> AND end_date_month_day
>
>
> That will return all the results between those months and days
> regardless of the year.
>
>
> Any help would be appreciated.
>
> Thanks, paul.


Can the dates span year boundaries?


Reply With Quote
  #3 (permalink)  
Old 04-23-2007
macca
 
Posts: n/a
Default Re: URGENT HELP NEEDED PLEASE! Selecting a date range without the year

Yes.

Ive figured it out now though thanks, i used

WHERE (MONTH(dates) BETWEEN month1 AND month2)


thanks anyway

Reply With Quote
  #4 (permalink)  
Old 04-24-2007
Captain Paralytic
 
Posts: n/a
Default Re: URGENT HELP NEEDED PLEASE! Selecting a date range without the year

On 23 Apr, 22:29, macca <ptmcna...@googlemail.com> wrote:
> Yes.
>
> Ive figured it out now though thanks, i used
>
> WHERE (MONTH(dates) BETWEEN month1 AND month2)
>
> thanks anyway


But does that work when month1 is November and month2 is January?

Also you haven't included the day part?

Reply With Quote
  #5 (permalink)  
Old 04-24-2007
macca
 
Posts: n/a
Default Re: URGENT HELP NEEDED PLEASE! Selecting a date range without the year

Well i did, i just didnt show it here. The where clause of the query
is:


WHERE (MONTH(PurchaseDate) BETWEEN #form.txtStartMonth# AND
#form.txtEndMonth#) AND (DAYOFMONTH(PurchaseDate) BETWEEN
#form.txtStartDay# AND #form.txtEndDay#) AND (YEAR(PurchaseDate)
BETWEEN #form.txtStartYear# AND #form.txtEndYear#) ORDER BY
PurchaseDate ASC

With each of DAYOFMONTH,MONTH & YEAR only being concatenated to the
where clause if the user sets one in the form


But you are right.This does not work when month1 is November and
month2 is January. I didnt even think of this


suggestion appreciated...


Reply With Quote
  #6 (permalink)  
Old 04-24-2007
Jerry Stuckle
 
Posts: n/a
Default Re: URGENT HELP NEEDED PLEASE! Selecting a date range without theyear

macca wrote:
> Well i did, i just didnt show it here. The where clause of the query
> is:
>
>
> WHERE (MONTH(PurchaseDate) BETWEEN #form.txtStartMonth# AND
> #form.txtEndMonth#) AND (DAYOFMONTH(PurchaseDate) BETWEEN
> #form.txtStartDay# AND #form.txtEndDay#) AND (YEAR(PurchaseDate)
> BETWEEN #form.txtStartYear# AND #form.txtEndYear#) ORDER BY
> PurchaseDate ASC
>
> With each of DAYOFMONTH,MONTH & YEAR only being concatenated to the
> where clause if the user sets one in the form
>
>
> But you are right.This does not work when month1 is November and
> month2 is January. I didnt even think of this
>
>
> suggestion appreciated...
>
>


Just check - if start month is > end month, ensure the purchase date is
NOT between end month and start month.

I'll leve the actual SQL up to you - but it's not much different than
what you have :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:28 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0