곽성훈
곽성훈

Reputation: 19

Sybase equivalent of Oracle TO_CHAR(datetime)

I changed my DB oracle -> sybase

So I should have to change my query.
But I don't know How to I convert my query

Furthermore I have to this query in both (oracle andn sybase => I can't use convert method )

my query is:

select ... 
TO_CHAR(Reg_Date,'yyyy/mm/dd hh24:mi:ss') Reg_Date....
from ...
where ...

Please help.

Upvotes: 1

Views: 3080

Answers (1)

markp-fuso
markp-fuso

Reputation: 35366

There are 4 different database products under the 'Sybase' name ... Adaptive Server Enterprise (ASE), SQLAnywhere, IQ, Advantage. You should provide the name of the database product; it also wouldn't hurt to provide the version, too.


Assuming you're working with ASE, you can use convert(to_datatype,value,date_format) to provide the desired output, eg:

select getdate(),convert(varchar,getdate(),121)
go
 -------------------  -------------------
 Jun 11 2017  8:02PM  2017/06/11 20:02:38

I'm not aware of a single query that would work in both Sybase (ASE) and Oracle.

Upvotes: 2

Related Questions