简体   繁体   English

Vertica中的函数是否等同于SQL中的DATENAME

[英]Is there a function in Vertica is equivalent to DATENAME in SQL

In sql i will get DateName from the following query 在sql中,我将从以下查询中获取DateName

SELECT DATENAME(dw,'10/24/2013') as theDayName

to return 'Thursday' 返回'星期四'

have any equivalent function in Vertica? 在Vertica中有任何等效功能吗?

The easiest way without using a custom UDF is using TO_CHAR formatting: 不使用自定义UDF的最简单方法是使用TO_CHAR格式:

SELECT TO_CHAR(TIMESTAMP '2014-08-21 14:34:06', 'DAY');

This returns the full uppercase day name. 这将返回完整的大写日名称。 Day gives the mixed-case day name, and day gives the lowercase day name. Day给出了大小写混合的日期名称,而day给出了小写的日期名称。

You can find more template patterns here . 您可以在此处找到更多模板模式。

You can try installing a custom UDF ( weekday_name ). 您可以尝试安装自定义UDF( weekday_name )。 Once installed, you can use: 安装后,您可以使用:

SELECT weekday_name(dayofweek(TO_DATE('10/24/2013','MM/DD/YYYY')))

Use this script, it will produce the desired result in Vertica 使用此脚本,它将在Vertica中生成所需的结果

SELECT DAYOFWEEK (TIMESTAMP '2014-08-21 05:26:24.000'); SELECT DAYOFWEEK(TIMESTAMP'2014-08-21 05:26:24.000');

Reference . 参考。 .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM