在Orcale中,用户可以通过下面的语句将date类型转换为char类型,那么在DBMaster中如何实现呢?
select * from QMDVFCMDBS where
sts_tkystr <= to_char(sysdate,'yyyymmdd') and sts_tkyend >= to_char(sysdate,'yyyymmdd')
DBMaster提供了转换函数,在DBMaster路径 \DBMaster\x.x\shared\udf下有两个转换函数todate 和 datetostr。不过用户需要先创建这个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)),'-','');