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: Examples of using the date and money functions
Date: Dec 10 1998 1:50AM

>>>>> "Larry" == Marcotte, Lawrence  writes:

    Larry> Does anyone have any good examples of
    Larry> a fetch loop that used datetime and money fields in their
    Larry> native formats and processes them using the functions in
    Larry> the SypPerl::CTlib::DateTime and/or SypPerl::CTlib::Money
    Larry> packages.

Here's a (trivial) example that should work:

#!/usr/local/bin/perl -w

use strict;

use Sybase::CTlib;

my $dbh = new Sybase::CTlib 'user', 'pwd', 'server';
$dbh->{UseDateTime} = CS_TRUE;

$dbh->ct_execute("select getdate()");
my $restype;
my @dat;
my $date;
while($dbh->ct_results($restype) == CS_SUCCEED) {
    next unless $dbh->ct_fetchable($restype);
    while(@dat = $dbh->ct_fetch) {
	$date = $dat[0];
    }
}

my @crack = $date->crack;
print "$date: @crack\n";
__END__;

prints:

kiruna (5:49pm):2 > perl crack.pl
Dec  9 1998  5:49PM: 1998 11 9 343 3 17 49 42 166 4046

Michael
-- 
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@mbay.net       -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com