简体   繁体   中英

Is there a function in Vertica is equivalent to DATENAME in SQL

In sql i will get DateName from the following query

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

to return 'Thursday'

have any equivalent function in Vertica?

The easiest way without using a custom UDF is using TO_CHAR formatting:

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.

You can find more template patterns here .

You can try installing a custom 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

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

Reference . .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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