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: Michael Peppler <mpeppler at MBAY dot NET>
Subject: Re: Perl Date/Time into Sybase
Date: Nov 25 1997 12:46AM

Ronald Page wrote:
> 
> I'm having trouble getting a Sybase Datetime field populated.  I've
> tried time(), localtime(time()) to no avail (can't use Integer and can't
> convert string).  I'm using CTlib, but I've also tried using DBGETTIME
> from DBlib.

Unfortunately Sybase does not understand the standard ctime(3)
format that localtime() outputs.

Write your own function to convert time() to a valid
string:

sub todatetime {
   my $time = shift;
   my @tm = localtime($time);
   $tm[4]++; #(month is 0 based)
   $tm[5] += 1900; #be y2k compliant :-)
   my $string = "$tm[5]-$tm[4]-$tm[3] $tm[2]:$tm[1]:$tm[0]";

   $string;
}

which you can call like this:

$datestring = todatetime(time);

Michael
-- 
Michael Peppler       -||-  Data Migrations Inc.
mpeppler@datamig.com  -||-  http://www.mbay.net/~mpeppler