日期怎么显示?

编程小战 2001-10-26 11:59:34
在Windows下我用ADO对象连到SQL Server,返回字段为日期,怎么转为字符显示?
如果要实现数据类型的相互转换,在Perl下怎么实现?
源程序如下:
#!D:/programs/perl/bin/perl
use CGI;
use Win32::OLE;
$oCgi=new CGI;
print $oCgi->header(-charset=>'GBK');
print "<h1>ActivePerl ADO test:</h1>";
print "<hr>";
print "Now connecting to demo database Northwind on local SQL Server:";
print "<hr>";
my $Conn =Win32::OLE->new('ADODB.Connection');
$Conn->Open("Driver=SQL Server;Server=(local);Database=Northwind;UID=sa;PWD=");
my $Rst=Win32::OLE->new('ADODB.RecordSet');
$Rst=$Conn->Execute("Select * from Employees");
if($Rst->Eof)
{
print "Sorry,no data!";
}
else
{
print "<table border=1 bordercolor=black cellspacing=0 cellblank=0>";
print "<tr bgcolor=#ff9900><td>Employee ID<td>Firstname<td>LastName<td>Title<td>BirthDate";
$Count=0;
do
{
print("<tr bgcolor=#00fff00>");
print("<td>");
print $Rst->Fields("EmployeeID")->Value;
print("<td>");
print $Rst->Fields("FirstName")->Value;
print("<td>");
print $Rst->Fields("LastName")->Value;
print("<td>");
print $Rst->Fields("Title")->Value;
print("<td>");
print $Rst->Fields("BirthDate")->Value;
$Rst->movenext;
$Count++;
}
while(not $Rst->Eof);
print "</table>";
}
$Rst->Close;
$Conn->Close;

日期字段(BirthDate)显示值:Win32::OLE::Variant=SCALAR(0x1792d9c)
...全文
17 点赞 收藏 回复
写回复
回复
切换为时间正序
请发表友善的回复…
发表回复

还没有回复,快来抢沙发~

发动态
发帖子
CGI
创建于2007-09-28

2176

社区成员

Web 开发 CGI
申请成为版主
社区公告
暂无公告