Gossamer Forum
Home : Products : DBMan : Customization :

Sort by Date Problems

Quote Reply
Sort by Date Problems
I am having a great deal of difficulty trying to figure out why my system is not sorting properly by date. I have looked and looked multiple times through the posts on the board and can't seem to find what the problem could be. Someone please help Crazy

I want to sort a specific artist appearances by event date and for some reason when I add a new booked date for an artist it doesn't want to sort the new date:

Here are the changes I made to the cgi file (made these changes according to one of the posts I referenced):

sub get_date {# --------------------------------------------------------
# Returns the date in the format "dd-mmm-yy".
# Warning: If you change the default format, you must also modify the &date_to_unix
# subroutine below which converts your date format into a unix time in seconds for sorting
# purposes.
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
($day < 10) and ($day = "0$day");
$mon += 1;
($mon < 10) and ($mon = "0$mon");
$year += 1900;
return "$mon\/$day\/$year";
}

sub date_to_unix {
# --------------------------------------------------------
# This routine must take your date format and return the time a la UNIX time().
# Some things to be careful about..
# int your values just in case to remove spaces, etc.
# catch the fatal error timelocal will generate if you have a bad date..
# don't forget that the month is indexed from 0!
#
my ($date) = $_[0];

my ($time);
my ($mon, $day, $year) = split(/\//, $_[0]);
unless ($day and $mon and $year) { return undef; }

use Time::Local;
eval {
$day = int($day); $year = int($year) - 1900; $mon = int($mon) - 1;
$time = timelocal(0,0,0,$day, $mon, $year);
};

if ($@) { return undef; } # Could return 0 if you want.
return ($time);
}


Here is my config set up:

'id' => [ 0, 'numer', -1, 255, 1, '', ''],
'dateadded' => [ 1, 'date', -1, 255, 1, &get_date(), ''],
'artistname' => [ 2, 'alpha', 0, 14, 1, '', ''],
'eventdate' => [ 3, 'date', 20, 255, 0, &get_date(), ''],
'tourtitle' => [ 4, 'alpha', 20, 255, 0, '', ''],
'venue' => [ 5, 'alpha', 20, 255, 0, '', ''],
'address' => [ 6, 'alpha', 20, 255, 0, '', ''],
'city' => [ 7, 'alpha', 20, 255, 0, '', ''],
'state' => [ 8, 'alpha', 20, 255, 0, '', ''],
'country' => [ 9, 'alpha', 20, 255, 0, '', '']

My database so far:

1|04/15/2003|Warp Brothers|04/23/2003|WARP FACTOR TOUR|Bikini's @ Rio|Rio Casino|Las Vegas|NV|USA|
2|04/15/2003|Warp Brothers|04/25/2003|WARP FACTOR TOUR|Arena|6655 Santa Monica Blvd|Hollywood|CA|USA|
3|04/15/2003|Warp Brothers|04/26/2003|WARP FACTOR TOUR|FUSION|69 South Division|Grand Rapids|Mich|USA|
4|04/15/2003|Warp Brothers|05/23/2003|WARP FACTOR TOUR|Detroit Music Festival||Detroit|MICH|USA|
5|04/15/2003|Warp Brothers|05/24/2003|WARP FACTOR TOUR|Detroit Music Festival||Detroit|MICH|USA|
6|04/15/2003|Warp Brothers|05/25/2003|WARP FACTOR TOUR|OASIS 160|160 W Joe Orr Road|Chicago Heights|IL|USA|
7|04/15/2003|Warp Brothers|05/29/2003|WARP FACTOR TOUR|CLUB KOBLAT|1221 Washington Ave|St Louis|MO|USA|
8|04/15/2003|Warp Brothers|05/30/2003|WARP FACTOR TOUR|WHITE STAR NIGHT CLUB|9819 Contant|Hamtramck|MI|USA|
9|04/15/2003|Warp Brothers|06/06/2003|WARP FACTOR TOUR|CLUB MONTAGE|2028 Hancock Street|San Diego|CA|USA|
10|04/15/2003|Warp Brothers|06/28/2003|WARP FACTOR TOUR|Ampitheatre|1609 East 7th AVE|Tampa|FL|USA|
11|04/15/2003|Warp Brothers|06/29/2003|WARP FACTOR TOUR|HOUSE OF BLUES||ORLANDO|FL|USA|
12|04/15/2003|Warp Brothers|07/04/2003|WARP FACTOR TOUR|ALPHA ZONE|Garfield Ave|Sacramento|CA|USA|
13|04/15/2003|Warp Brothers|07/05/2003|WARP FACTOR TOUR|SPLASH FESTIVAL|Trible Camp Ground|Seattle|WA|USA|
14|04/15/2003|Drastik|04/23/2003|WARP FACTOR TOUR|Bikini's|RIO CASINO|LAS VEGAS|NV|USA|
15|04/15/2003|Drastik|04/25/2003|WARP FACTOR TOUR|ARENA||HOLLYWOOD|CA|USA|
16|04/15/2003|Louis Osbourne|05/24/2003|HOMELANDS|Matterley Bowl||Winchester||UK|
17|04/15/2003|Louis Osbourne|06/08/2003||Q PALACE|BAD NENNDORF|HANNOVER||GERMANY|
18|04/15/2003|LOUIS OSBOURNE|06/12/2003|Motion AUDIO TOUR|DISCOTHEQUE|19street (bt 5 & 6 AVE)|NEW YORK|NY|USA|
19|04/15/2003|Louis Osbourne|06/13/2003|MOTION AUDIO TOUR|NATION||WASHINGTON DC||USA|
20|04/15/2003|Louis Osbourne|06/20/2003|MOTION AUDIO TOUR|CLUB MONTAGE|2028 Hancock Street|San Diego|CA|USA|
21|05/07/2003|LOUIS OSBOURNE|06/21/2003|MOTION AUDIO TOUR|SPUNDAE||CHICAGO|IL|USA|
22|04/15/2003|Louis Osbourne|06/24/2003|MOTION AUDIO TOUR|STUDIO 54 / EDEN|MGM GRAND|LAS VEGAS|NV|USA|
23|04/15/2003|LOUIS OSBOURNE|07/10/2003|MOTION AUDIO TOUR|CLUB KOBALT|1221 Washington Ave|ST LOUIS|MO|USA|
25|04/15/2003|Louis Osbourne|07/18/2003|MOTION AUDIO TOUR|SPUNDAE|1015 Folsum|San Fran|CA|USA|
26|04/15/2003|Louis Osbourne|07/19/2003|MOTION AUDIO TOUR|SPUNDAE|6655 Santa Monica Blvd|Hollywood|CA|USA|
27|05/07/2003|LOUIS OSBOURNE|07/26/2003|MOTION AUDIO TOUR|HEAVEN @ NOISELAB|925 E Pike St|SEATTLE|WA|USA|
28|05/07/2003|LOUIS OSBOURNE|07/11/2003|MOTION AUDIO TOUR|GROUND ZERO|Streeters|TRAVERSE CITY|MICH|USA|

And the results that are being displayed for one of the artists (in which the date is displayed wrong):

05/24/2003 Matterley Bowl Winchester, UK
06/08/2003 Q PALACE HANNOVER, GERMANY
06/12/2003 DISCOTHEQUE NEW YORK, NY, USA
06/13/2003 NATION WASHINGTON DC, USA
06/20/2003 CLUB MONTAGE San Diego, CA, USA
06/21/2003 SPUNDAE CHICAGO, IL, USA
06/24/2003 STUDIO 54 / EDEN LAS VEGAS, NV, USA
07/10/2003 CLUB KOBALT ST LOUIS, MO, USA
07/18/2003 SPUNDAE San Fran, CA, USA
07/19/2003 SPUNDAE Hollywood, CA, USA
07/26/2003 HEAVEN @ NOISELAB SEATTLE, WA, USA
07/11/2003 GROUND ZERO TRAVERSE CITY, MICH, USA

Notice that the last date is out of order. Can anyone tell me why this could be happening?
Cher
Quote Reply
Re: [chronisca] Sort by Date Problems In reply to
Could you send a sample of the "search string" used to produce the results?