PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Steve Allen <sallen at sybase dot com>
Subject: Problem with DATETIME value.
Date: Apr 24 1998 7:40AM

Folks,

I have a problem with using datetime can anybody help,

The following code can be run any number of times depending on how many
times the user select next from a selection box, but on the third
attempt all seems ok if print the values before for mon,year,day all
seems fine but after passing into the newdate function it is reset to 1
jan 1900, but it works the first two times.?

$startdate = Sybase::DBlib::DateTime;

        if($week eq "N")
        {
                $startdate = $dbh->newdate($whatdate);
                $startdate = $startdate->calc(1,0);
                print "startdate calc = $startdate";
               print "StartNext  = $startdate
"; } else { if($week eq "P") { $startdate = $dbh->newdate($whatdate); $startdate = $startdate->calc(-1,0); print "StartPrev = $startdate
"; } else { $startdate = $dbh->newdate(syb_time(localtime)); } } ($year, $mon, $mon_day, $year_day, $week_day, $hour, $min, $sec, $msec, $zone) = $startdate->crack; if($week_day >= 1) { $startdate = $startdate->calc(-($week_day-1), 0); } else { $startdate = $startdate->calc(1, 0); } ($year, $mon, $mon_day, $year_day, $week_day, $hour, $min, $sec, $msec, $zone) = $startdate->crack; #adjust incorrect month + 1 $mon = $mon +1; if($mon < 10) { $mon = sprintf ( "0%d", $mon); } print "Date = Year:$year Mon$mon MonDay$mon_day"; - eveything ok upto here $startdate = $dbh->newdate("$year$mon$mon_day"); -- after this call it is reset only on third call from post of CGI? Kind Regards Steve Allen.