sql - Custom Postgres function for term dates and times -


lets have large table consists of 3 columns.

integer id, timestamp ts, double value

if wanted values given complicated date expression best way achieve ?

for example if wanted values @ anytime on weekend days , between 18:00 , 8:00 on weekdays , time on school holidays year 2014.

obviously of these times variable , solution should dynamic. thinking of storing series of date intervals things school holidays in table check against. however, create custom postgres function hide of complexity.

does know of similar code or have suggestions ? dealing cases times above except on weekend logic ?

thanks

with holiday table

select *     t     left join     holiday on date_trunc('day', t.ts) = holiday.day     extract(dow ts) in (0, 6) -- weekend     or     (extract(hour ts) >= 18 , extract(hour ts) <= 8)     or     holiday.day not null -- holiday 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -