在 Oracle 的 to_char 中转义非格式字符的最佳方法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/588430/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 17:51:44  来源:igfitidea点击:

What is the best way to escape non-format characters in Oracle's to_char?

sqloracleto-char

提问by Sixty4Bit

I am trying to print a date in a select statement, but I need to add a letter to the output:

我试图在 select 语句中打印日期,但我需要在输出中添加一个字母:

to_char(date_updated, 'YYYY-MM-DDTHH:mm:ss')

Oracle does not like the T. I just want the T to be output like the colons and the dashes. Can I escape it with a backslash or something?

Oracle 不喜欢 T。我只希望 T 像冒号和破折号一样输出。我可以用反斜杠或其他东西来逃避它吗?

回答by Chad Birch

You just need double-quotes around it:

你只需要在它周围加上双引号:

to_char(date_updated, 'YYYY-MM-DD"T"HH:mm:ss')