Re: inevitability of to_date() when convertingrepresentations which don't represent whole timestamps

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: inevitability of to_date() when convertingrepresentations which don't represent whole timestamps
Дата
Msg-id CAKFQuwboSTceFLyhfyvzpcFuuG=gQJdjDrrKyTOtY7mvSh6Q+g@mail.gmail.com
обсуждение исходный текст
Ответ на inevitability of to_date() when converting representations whichdon't represent whole timestamps  (Shaun Cutts <shauncutts@factfiber.com>)
Список pgsql-general
On Thu, Mar 30, 2017 at 8:21 AM, Shaun Cutts <shauncutts@factfiber.com> wrote:

My use case is to convert the name of a day to a day of the week number — now testing in English, but ultimately locale insensitive, so relying on to_date() to recognize the day in whatever the database locale is.


​Patches are welcome but I'd suggest that you not attempt to incorporate this behavior into to_date.  That function returns a date and what you want is a normalized integer (or, in reverse, a locale-specific string).

Both locale-specific so stable, not immutable:
day_of_week(text) : integer
day_of_week(integer) : text

Given that "select to_char(now(), 'Day')" works there should be few, if any, technical barriers to overcome.

You'd need to decide whether to support only the  "ISO 8601" numbering scheme (1-7) or to add additional arguments and/or function to number Sunday as 0 instead of 7.

David J.

В списке pgsql-general по дате отправления:

Предыдущее
От: harpagornis
Дата:
Сообщение: Re: Tablespace Default Behavior
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Tablespace Default Behavior