in reply to Using DBI::Sybase having problem with Date format

select convert( char(8), gedate(), 1 )
will convert the current date to mm/dd/yy. Although I would probably use
select convert( char(10), getdate(), 101 )
to get mm/dd/yyyy. So just change getdate() with your DATETIME column.

-derby

Replies are listed 'Best First'.
Re^2: Using DBI::Sybase having problem with Date format
by Anonymous Monk on May 10, 2007 at 17:18 UTC
    Thanks for the quick reply. I am looking at where I would include this in the script that i attached would I have to run the above as a seperate sql query within that script?

      I don't know which columns are dates (so, I'll assume those prefixed with dt are). For your test script, you would have to change from

      my $sth = $dbh->prepare_cached( "SELECT * FROM ReleaseDates" );
      to
      my $sth = $dbh->prepare_cached( "SELECT convert( char(8), dtXXX, 101 ) FROM ReleaseDates" );
      for the cgi:
      my $sth =$connection->prepare( "SELECT Release, dtTargetFeatureFreeze, dtTargetCCRB, dtTargetReleaseFromDev, dtTargetRTM, TwikiURL, ReleaseNum, Display FROM ReleaseDates WHERE (Display = 1)" );
      to
      my $sth =$connection->prepare( "SELECT Release, convert( char(8), dtTargetFeatureFreeze, 1), convert( char(8), dtTargetCCRB, 1), convert( char(8), dtTargetReleaseFromDev, 1), convert( char(8), dtTargetRTM, 1), TwikiURL, ReleaseNum, Display FROM ReleaseDates WHERE (Display = 1)" );
      -derby

      update: BTW, setting dateformat only affects inputting dates.

        Derby thank you so much !!! I have used your method on quite a few of my scripts now. Your an absolute legend. Thanks again for all your help. Michael I did try the whole
        $dbh->syb_date_fmt('MDY1_YYYY');
        but it just wouldn't workmaybe it was the way i was trying to include it into my script I will probably try and get it to work if i can. Thank you both for all your help