提一个SQL的问题?(50分)

K

kk2000

Unregistered / Unconfirmed
GUEST, unregistred user!
select typeid,name,address,substring(cast(birthday as char(16)),12,16) as birthday from test;
为什么上面的语句显示出来的时间不是按数据库里面的时间显示了!
举个例子: birthday 是datetime的类型,如果时间是“2003-08-04 19:09:00"的话,
上面的语句显示结果是“7:09",我想要的结果是"19:09“,怎么解决?
还有我又写了下面的语句:
select typeid,name,address,convert(varchar(16), birthday,108) as birthday from test;
但是有显示秒了!我不想秒也显示出来!该怎么办?
 
select typeid,name,address,substring(convert(varchar(16), birthday,108),1,17) as birthday from test
 
设置LongDateFormat参数
 
我觉得在前端处理比较好(设置这列的显示格式),要是保存的是短日期格式或者年月象这样保存的03-7-8你的程序怎么处理?
 
TO:southman
select typeid,name,address,substring(convert(varchar(16), birthday,108),1,17) as birthday from test
我修改一下你的语句就OK了!谢谢。
我觉得自己不开窍!呵呵
select typeid,name,address,substring(convert(varchar(16), birthday,108),1,5) as birthday from test
 
看看还有什么好的方法!等一会儿结贴。
 
多人接受答案了。
 

Similar threads

S
回复
0
查看
747
SUNSTONE的Delphi笔记
S
S
回复
0
查看
696
SUNSTONE的Delphi笔记
S
顶部