|
|
sybperl-l Archive
Up Prev Next
From: "Perumal, Saravana" <Saravana dot Perumal at fmr dot com>
Subject: how to select - date values from getdate() in sybperl.
Date: Oct 11 1998 4:41PM
Hi,
I am trying to get the date and time in various formats from sybase,
I have few sample sql's which I try to execute from perl using sybperl.
I am not getting any results.
Could anyone provide information about how I should do this.
Thanks,
Saravana Perumal.
------------------------------------------------------------------
declare @enddate char(30)
select @enddate = convert(char(30),getdate(),109)
select @enddate
----------------------------------------------------------------
declare @edate char(6), @hour char(2), @amin char(2), @sec char(2)
select @edate = convert(char(6), getdate(),12)
select @hour =
convert(char(2),datepart(hour,convert(char(8),getdate(),8)))
select @amin =
convert(char(2),datepart(minute,convert(char(8),getdate(),8)))
select @sec =
convert(char(2),datepart(second,convert(char(8),getdate(),8)))
select @edate
select @hour
select @amin
select @sec
--------------------------------------------------------------------
The perl script I used to do this is: Please let me know the
correct way of doing.
#!/usr/local/perl/bin/perl
use Sybase::CTlib;
$dbh = Sybase::CTlib->ct_connect('user','pass','serv','db');
$stt = "declare \@edate char(30)";
$stt .= " SELECT \@edate = convert( char(30), getdate(), 109) ";
print $stt;
$dbh->ct_execute("$stt");
while (( $rc = $dbh->ct_results($restype)) == CS_SUCCEED)
{
next if ( $restype == CS_CMD_FAIL || $restype == CS_CMD_SUCCEED
|| $restype == CS_CMD_DONE);
while (%dat = $dbh->ct_fetch(1))
{
print "Test";
print "Value --> $dat{edate}\n";
}
}
|