| От | Steve Crawford |
|---|---|
| Тема | Re: query by partial timestamp |
| Дата | |
| Msg-id | 50ECA5DE.3060103@pinpointresearch.com обсуждение исходный текст |
| Ответ на | query by partial timestamp (Kirk Wythers <kwythers@umn.edu>) |
| Список | pgsql-general |
On 01/08/2013 02:19 PM, Kirk Wythers wrote: > I have a column of type TIMESTAMP, I'd like to query all records from 2011. If it were text I could use a partial suchas: > > WHERE > text ~ '2011' > > There must be a simple way to pull the year part out of a timestamp format. Thanks in advance. > > > > As others pointed out, you can do this with "extract(...). BUT, if your timestamp column is indexed (and if the index will constrain your records to a sufficiently small subset of the table that use of indexes is warranted) you may be better off using date comparisons. I doubt the planner will use the indexes otherwise. Cheers, Steve
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера