如何在Teradata/SQL中获得上个月和现年
我需要一个简单的teradata/sql语句,该语句以以下格式提供上个月和当年。在这种情况下为'03 2022'。
我试图以exc the the the the命令以'04/15/2022'的形式解决当前日期的类似请求
选择current_date(格式'mm/dd/yyyy')(char(12))为'new_format'。
但是现在,我正在努力获得“ MM Yyyy”的确切价值,该价值给了上个月和当年。
我尝试了几个演员和cont饮,但似乎没有一个。请引导我。
先感谢您。
I need a simple TERADATA/SQL statement which gives previous month and current year in the following format. In this case as '03 2022'.
I have tried to solve a similar request for current date in required format as '04/15/2022' by exec the below command
SELECT CURRENT_DATE(FORMAT 'mm/dd/yyyy') (CHAR(12)) as 'New_format'.
But now I am struggling to get exact value as 'mm yyyy' which gives previous month and current year.
I have tried several CAST and CONCAT, but none seems to be working. Please guide me.
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
返回varchar的哪个
- 然后可以在需要时施放给炭,或者
是旧语法
Either
which returns VARCHAR - could then CAST to CHAR if needed, or
or legacy syntax
我会把它作为评论,但我没有足够的声誉。
选择日期 - 间隔'1'月
在链接中有关它的更多信息:
I would leave it as a comment but I dont have enought reputation.
SELECT DATE - INTERVAL '1' MONTH
More about it in link:
https://etl-sql.com/teradata-date-functions/