This seems to be related to the first expression which is not a TIMESTAMP WITH TIME ZONE data type altough SWITCHOFFSET expects that. The following fails for me on 16.0.0.2270 (with a -157 SQLCODE as in your test): select switchoffset(current timestamp, '-07:00'); whereas the following work as expected: select switchoffset(current utc timestamp, '-07:00'); select switchoffset(cast(current timestamp as timestamp with time zone), '-07:00'); select switchoffset(current utc timestamp, -420); select switchoffset(current timestamp, -420); select switchoffset(cast(current timestamp as timestamp with time zone), -420); So I think you have to cast the first expression to the expected data type... answered 28 Sep '16, 03:57 Volker Barth Funny that the wrong input works with an integer as the second parameter
(28 Sep '16, 05:48)
Martin
|
What is exactly broken in your estimate here?
The example given for this function works as documented in 16 (your build or the most recent) and 17 for me. Even when I specify both hours and minutes with
It is possible you are supplying it as an integer?
If so, that would also be as documented:
Maybe you can show us what you mean then?
It seems to work for me (either way). For example:
SELECT CAST ( '2009-04-03 14:45:12.123-04:00' AS datetimeoffset ) AS EDT, SWITCHOFFSET( EDT,-420 ), SWITCHOFFSET( EDT,420 );
returns
SELECT SWITCHOFFSET(current time,'-07:00')
leads to the error:
ERROR [07006] [Sybase][ODBC Driver][SQL Anywhere]Cannot convert '-07:00' to a integer
So you have to use an integer and cannot as described use a textual representation
See above the usage of a string is not possible