Skip to content
Advertisement

Convert day of week name to day of week number Vertica

  • With this way – SELECT TO_CHAR(NOW(), 'DAY'); I can get a day of week name(E.G. MONDAY).
  • With SELECT dayofweek(NOW()); I can get the number of the day of week. (E.G 1)
  • QUESTION: How to convert day of week name to day of week number. (E.G MONDAY -> 1) SMTH like TO_NUMBER('MONDAY', 'DAY'); --> 1 (just for example, don’t working)

Advertisement

Answer

Probably a case expression is the simplest method:

Or arrays are more concise:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement