The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

My ugly SQL by stoft 2007-04-26 05:53:45
One of my spare time problems. I have the following which is functional (I hope, it hasn't been tested much) but imho quite ugly:

SELECT my_date + (CASE WHEN my_date BETWEEN next_day( to_date( extract(YEAR FROM my_date)||'0324','YYYYMMDD'), 'Sunday') AND next_day( to_date(extract(YEAR FROM my_date)||'1024','YYYYMMDD'), 'Sunday') THEN 2 ELSE 1 END)/24 FROM my_table;

What it does:
Selects any my_date +1 or +2 hours depending on DST. Some of the ugliness is caused by the need to take into consideration the year of my_date when calculating DST.

Anyone have an idea how to, if possible, make it more elegant? The environment is oracle 9.2.
[ Reply ]
  Rewriting it helps quite a lot by sazzer2007-04-26 06:54:42
  I'll see your SQL and raise you a RegExp by madjo2007-04-26 07:42:43

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)