This is embarrassing, but I am going nuts here.
Today is monday. Around here, this is the first day of the week.
So,
Fine, that is probably becuase of my NLS settings: Let’s change it then, into something where people know that monday is the first day of the week 😉 No luck, how about Wrong variable, maybe. How about NLS_TERRITORY
Great! — But I don’t like to alter session like this, and Dang, out of ideas. Am I just on a mission impossible here?
- 332847 Просмотров
- Метки: нет (добавить)
1. Re: Day of week (1-7) and NLS settings
The datetime format element D returns the number of the day of the week (1-7). The day of the week that is numbered 1 is specified implicitly by the initialization parameter NLS_TERRITORY.
The ‘nlsparam’ argument specifies the language in which month and day names and abbreviations are returned. This argument can have this form:
So ‘D’ is controlled by NLS_TERRITORY and the TO_CHAR function can only handle NLS_DATE_LANGUAGE.
So it looks like ALTER SESSION is your only way out here.
2. Re: Day of week (1-7) and NLS settings
Great! — But I don’t like to alter session like this
3. Re: Day of week (1-7) and NLS settings
D >Day of week (1-7). This element depends on the NLS territory of the session.
@Hoek, wouldn’t that be great, but unfortunately it can be all sorts of things "Around here" not all are Danish 😉
- Мне нравится Показать отметки "Мне нравится" (0) (0)
- Действия
4. Re: Day of week (1-7) and NLS settings
5. Re: Day of week (1-7) and NLS settings
What is the problem?
Do you just want an expression that, given a DATE, will return an integer (1 for Monday, . 7 for Sunday), independent of NLS settings?
If so:
- Мне нравится Показать отметки "Мне нравится" (1) (1)
- Действия
6. Re: Day of week (1-7) and NLS settings
return an integer (1 for Monday, . 7 for Sunday), independent of NLS settings?
That’s right Frank,
and cool, thank you!
@Michaels, thanks for reminding me about fill mode, which I of course forgot about it
Используя Oracle SQL, как создать набор результатов для:
- номер дня недели (1-7)
- Название дня (понедельник, вторник, среда и т. д.)
2 ответа
Флорин отвечает, как я это сделаю, но вы должны быть немного осторожны с NLS . На день недели влияет территория NLS, поэтому, если я запускаю ее так, как будто я нахожусь в США, она работает:
Но тот же запрос, выполняемый в Великобритании, — выходной.
. и мне нужно скорректировать расчет, чтобы исправить это:
Вы также можете отдельно указать язык, используемый для названий дней:
Базы данных
В этом учебном пособии вы узнаете, как использовать Oracle/PLSQL функцию NEXT_DAY с синтаксисом и примерами.
Описание
Oracle/PLSQL функция NEXT_DAY возвращает первый день недели, который больше date .
Синтаксис
Синтаксис Oracle/PLSQL функции NEXT_DAY:
Параметры или аргументы
date используется для поиска следующего дня недели
weekday это день недели (это: понедельник, вторник, среда, четверг, пятница, суббота, воскресенье)
Функция NEXT_DAY возвращает значение date.
Применение
Функцию NEXT_DAY можно использовать в следующих версиях Oracle/PLSQL:
- Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i
Пример
Рассмотрим несколько примеров функции NEXT_DAY и изучим, как использовать функцию NEXT_DAY в Oracle/PLSQL.