我想以这样的格式获取日期 yyyy-mm-dd, ,例如 2014-04-11.但似乎没有办法做到这一点在Sybase(ASE12.5)与 转换/转换 函数。

目前,我得到112的日期,并添加 - 位数之间。有什么好办法吗?

有帮助吗?

解决方案

试试这个:

select str_replace( convert( varchar, col1, 111 ), '/', '-') 
from table

其他提示

利用格式140:yyyy-mm-dd hh:mm:ss。ssssss

使用char(10)使Sybase将字符串截断为前10个字符,即

convert(char(10), col1, 140)

查看共享的表文档 多伯伦, ,表有所有的格式。我试了一下,效果很好:

SELECT convert(char(10),dateadd(month,-1, convert(date,getdate())),112)  from table;

我的查询格式是yyyymmdd。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top