Cannot covert to a timestamp 是什么意思?

lijun521 2003-08-27 08:25:15


string s,l
long li_count
s=sle_1.text
l="出生年月 like'"+s+"%'"
select count(*) into :li_count from student
where 出生年月=:s;
if li_count<1 or isnull(li_count) then
messagebox('提示','无此出生年月!')
end if
dw_1.setfilter(l)
dw_1.filter()

为什么我保存这段代码的时候 会提示错误说:

Cannot covert to a timestamp

是什么意思? 高手教教我!!
...全文
294 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackxrh 2003-08-28
  • 打赏
  • 举报
回复
timestamp 是 SQL Server 里的一个数据类型 .. 一般的没有谁用这个类型的 ..

你查看一下它的数据格式,看看和字符串进行转化时的格式是怎么样的
纳米茶 2003-08-27
  • 打赏
  • 举报
回复
刚才出去吃消夜去了,呵呵,忘记问你用的是不是sybase了
runsoft 2003-08-27
  • 打赏
  • 举报
回复
还不清楚呀。 (lijun) ,好像你在 QQ群里面问过哦。
liujiaqiang 2003-08-27
  • 打赏
  • 举报
回复
先问问你:sle_1.text里面的数据为什么格式的,你先用Messagebox("",string(s))看看是什么格式。
如果为:yyyy-mm-dd格式,则应该这样写:
string s,l
long li_count
s=sle_1.text
l=" string(出生年月,"yyyy-mm-dd") like '"+s+"%' " //记得like和'之间用空格的。
select count(*) into :li_count from student
where convert(char(10),出生年月,120) = :s ;
if li_count<1 or isnull(li_count) then
messagebox('提示','无该出生年月!')
end if
dw_1.setfilter(l)
dw_1.filter()


如果格式为:yyyymmdd 则这样写:

string s,l
long li_count
s=sle_1.text
l=" string(出生年月,"yyyymmdd") like '"+s+"%' " //记得like和'之间用空格的。
select count(*) into :li_count from student
where convert(char(8),出生年月,112) = :s ;
if li_count<1 or isnull(li_count) then
messagebox('提示','无该出生年月!')
end if
dw_1.setfilter(l)
dw_1.filter()

根据格式看,你自己试试吧。
lijun521 2003-08-27
  • 打赏
  • 举报
回复
string s,l
long li_count
s=sle_1.text
l="convert(char(8),出生年月,112)) like'"+s+"%'"
select count(*) into :li_count from student
where convert(char(8),出生年月,112) =:s;
if li_count<1 or isnull(li_count) then
messagebox('提示','无该出生年月!')
end if
dw_1.setfilter(l)
dw_1.filter()

改了 不行 :(`~`~
纳米茶 2003-08-27
  • 打赏
  • 举报
回复
我想你想做的是通过sle_1的输入,在dw_1中过滤出相似的记录出来。你没有通过转换是不可能对date类型的数据进行like查询操作的!
我忘记了正确的转换格式了,你可以改改

select count(*) from student
where convert(char(8),出生年月,112)) like :s;
jdsnhan 2003-08-27
  • 打赏
  • 举报
回复
数据库是什么?"出生年月"是字段名吗?
lijun521 2003-08-27
  • 打赏
  • 举报
回复
这样我的查询条件就是 在哪年和哪年之间出生的人了?~``
纳米茶 2003-08-27
  • 打赏
  • 举报
回复
建议你这样写:
date date_1,date_2
//////date_1和date_2赋值
select count(*) into :li_count from student
where 出生年月 >=:date_1 and 出生年月 <date_2 ;
lijun521 2003-08-27
  • 打赏
  • 举报
回复
那我执行的时候也不行啊 我到底该怎么做呢?!!!
lijun521 2003-08-27
  • 打赏
  • 举报
回复
我的出生年月是date型的 这个有没有关系啊? 如果有 我该怎么修改出生年月的类型?

我在数据库里面直接修改好象不行 。。:
纳米茶 2003-08-27
  • 打赏
  • 举报
回复
出生年月是一个字段,而且是一个时间类型。你定义的s变量是一个string类型的变量,本身时间类型的变量就不可能等于一个string类型的变量,这还不算你的sql语法错误。

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧