in reply to Trying to order by date

Of course, you understand that this has nothing to do with Perl :)
i tried to cahnge the msyql column of date fro m text to datetime but what i get is 00-00-00 00:00:00
If you have to handle a datetime, use a datetime and not a text. There are two considerations about this: You'll surely want your script to work in 2105 too, so you'd better use four-digit years via %Y instead of %y :)

If you fix the dates in your guestlog table you'll obtain what you're looking for, the query is right.

Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf

Don't fool yourself.

Replies are listed 'Best First'.
Re^2: Trying to order by date
by Nik (Initiate) on Aug 04, 2005 at 11:17 UTC
    Year is not a problem and actually i dotn wanty it:
    So the solutuon is to change this my $date = strftime( '%F %T', localtime ); to this? my $date = now();
    and then insert it to the mysql database?

    But then agian when i get th date column form the mysq table i want to print it in this format my $date = strftime( "%d %b, %H:%M", localtime );
      No, you just want something like the following SQL:

      "UPDATE sometable SET datecolumn = NOW() where ID=..."

      There is no need to generate the date in perl.

      Update: by the way, YOU might not be interested in the year (as in, you might not want to show it) but the database can't sort the dates correctly if you don't supply a year: jan 2004 IS later than dec 2003, you see.

      Update2: if you have a datetime column, mysql can take care of the output formatting too. You desperately need to take a look at the mysql date and time functions instead of guessing.

      A reply falls below the community's threshold of quality. You may see it by logging in.