How to get the number of the day of the week PL SQL ORACLE regardless of language

1

The idea is to be able to get the number of the week in a function in ORACLE but that it will always return the same values regardless of the language configuration so as not to give wrong calculations in the dates,

for example Spanish:

  L M M J V S D
  1 2 3 4 5 6 7

English:

  D L M M j V S
  1 2 3 4 5 6 7

The function I have for this is:

  to_number(to_char(parametro_fecha,'D'))
    
asked by Paulker 02.06.2017 в 17:27
source

1 answer

1

The function to validate this always in the same language is validated with the language configuration in the TO_CHAR

 to_number(TO_CHAR(TO_DATE(p_fecha, 'DD/MM/YYYY'), 'D', 'NLS_DATE_LANGUAGE=ENGLISH'))

ENGLISH is placed if you want Sunday to be equal to 1

or

SPANISH if you want the day Monday to be equal to 1

 to_number(TO_CHAR(TO_DATE(p_fecha, 'DD/MM/YYYY'), 'D', 'NLS_DATE_LANGUAGE=SPANISH'))
    
answered by 02.06.2017 / 17:27
source