Adding a date and an interval...

Поиск
Список
Период
Сортировка
Искать

Adding a date and an interval...

От:
"Ian Harding" <ianh@co.pierce.wa.us>
Дата:
Why does this happen?  When I do this, 

select cast('10/28/01' as date) + cast('1 day' as interval);

I get 2001-10-28 23:00:00-08, when I expect 2001-10-29 etc.  I am using this in a loop in a pltcl function.

I know this is the end of daylight savings, but I assumed 1 day is not always 24 hours if the DB knows about daylight savings.

How should I go about consistently stepping through the days of the year?

Thanks!!

Ian A. Harding
Programmer/Analyst II
Tacoma-Pierce County Health Department
(253) 798-3549
mailto: ianh@tpchd.org

Re: Adding a date and an interval...

От:
"Len Morgan" <len-morgan@crcom.net>
Дата:
>select cast('10/28/01' as date) + cast('1 day' as interval);
>
>I get 2001-10-28 23:00:00-08, when I expect 2001-10-29 etc.  I am using
this in a loop in a pltcl function.

I believe you can use tcl instead of a select:

return clock format [expr [clock scan '10/28/01'] + 86400] -format
"%Y-%m-%d"

This should be every bit as fast as using a SELECT.

len morgan

FAQ