Skip to main content

How i will get DATENAME in vertica?

  • August 21, 2014
  • 4 replies
  • 10 views

Haris_NI
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?

4 replies

eli_revach
Forum|alt.badge.img+2
  • Participating Frequently
  • August 21, 2014
Vertica as the abiliy to return the date of the week as numeric value ,  you can do someting like this to have it as a string . 

SELECT  case  EXTRACT(DOW FROM TIMESTAMP '10/24/2013')       
         when 0 then 'Sunday'
          when 1 then 'Monday'
          when 2 then 'Tuesday'
          when 3 then 'Wednesday'
          when 4 then 'Thursday'
          when 5 then 'Friday'
          when 6 then 'Saturday'
       end 

Daniel_Leybovic
Forum|alt.badge.img+1
  • Participating Frequently
  • August 21, 2014
Hi!

You can find some useful functions here: https://github.com/sKwa/vertica/blob/master/UDFSQL/sql_funcs.sql
  • is_int
  • month_name
  • weekday_name
  • random_ts [between ts1 and ts2]
  • midpoint_timestamp
  • season
  • is_leap_year
  • current_quarter_last_day
Best (aka sKwa)



Bhawana
Forum|alt.badge.img
  • Participating Frequently
  • August 22, 2014

norbert_krupa
Forum|alt.badge.img+2
  • Participating Frequently
  • August 24, 2014
Use 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.