在Orcale中,用户可以通过下面的语句将date类型转换为char类型,那么在DBMaster中如何实现呢?

~ 0 min
2016-02-23 07:58

select * from QMDVFCMDBS where

sts_tkystr <= to_char(sysdate,'yyyymmdd') and sts_tkyend >= to_char(sysdate,'yyyymmdd')

 

DBMaster提供了转换函数,在DBMaster路径 \DBMaster\x.x\shared\udf下有两个转换函数todatedatetostr不过用户需要先创建这个UDF。

或者,通过下面的语句实现:

select replace(cast(curdate() as char(10)),'-','') as new_char;

假设有一个表的模式如下:

create table SYSADM.B (

 STS_TKYSTR  CHAR(10) default null ,

 STS_TKYEND  CHAR(10) default null )

可以像下面这些select:

select * from b where STS_TKYSTR <= replace(cast(curdate() as char(10)),'-','') and STS_TKYEND >= replace(cast(curdate() as char(10)),'-','');

平均分: 0 (0 投票)

你不能对该内容发表评论

标签