Syam asked a while ago how we could find something like the first Monday or third Saturday in a month. Well Syam, it’s taken me a while to respond but here we go.

For this example we’ll use sysdate as input but any Oracle date will work. You can also substitute any other day of the week for Monday.

The first day of the month is probably a good place to start:

SQL> select sysdate from dual;

SYSDATE
---------
18-JUL-06

SQL> select trunc(sysdate, 'MONTH') FROM DUAL;

TRUNC(SYS
---------
01-JUL-06

Now that we’ve got that we can find the first Monday with the next_day function. Of course we need to remember the next_day function looks for the next named day after the date provided so we subtract 1 day from the date in case the first is a Monday.

SQL> select next_day(trunc(sysdate, 'MONTH')-1, 'Monday') from dual;

NEXT_DAY(
---------
03-JUL-06

Now that we have the first Monday of the month we can add 7 days to find the second Monday or 14 to find the third.

SQL> select next_day(trunc(sysdate, 'MONTH')-1, 'Monday')+7 FROM dual;

NEXT_DAY(
---------
10-JUL-06

SQL> select next_day(trunc(sysdate, 'MONTH')-1, 'Monday')+14 FROM dual;

NEXT_DAY(
---------
17-JUL-06

So from here you can change the day you’re looking for or the week number you want it in.

oracle, date functions, sql, database, database development, pl/sql

Well, for those of you who actually follow this blog you may be wondering why I haven’t been posting as many stories lately. Here are the top reasons:

  1. There have been lots of comments here lately and I still try to respond to them all
  2. I’ve been playing Brain Age Sudoku on the Nintendo DS
  3. I found the best beer store in Concord, NH (USA)
  4. The air conditioner broke at work and I just don’t have the brain power left after a day in 90 degree heat
  5. I picked the wrong day to stop sniffing glue

So if you’ll bear with me, I’m doing my best to cool down, sober up, and break my Sudoku habit. Believe me, all three are tough, and in truth the only one I’m really trying to do is cool down.

Bear with me and stay tuned for more things that occasionally roll around in my head.

Jon

Brotherhood of the BeanFor the sadly misguided reader who wishes to read about coffee that hasn’t passed through the guts of a small mammal I give you Brotherhood of the Bean.

These guys are relatively new on the scene but it’s quite clear from their coffee talk and product reviews that they’re very serious about their bean. Hopefully the Brotherhood will maintain the quality of their content and continue posting frequently.

coffee, cafe, food, dining, food

News has broken today of the death of Roger Keith “Syd” Barrett, founding member of Pink Floyd. He died last Friday (July 7, 2006) at his home in Cambridgeshire, England of diabetes-related illness.

Syd will be remembered for his contributions to the psychedelic rock genre and for founding the world’s greatest rock band.

For more reading about Syd, check out the Wikipedia article on Syd for some good biographical info on him.

pink floyd, psychedelic rock, syd barrett, rock, music

Two interesting articles about bad habits some bloggers seem to have. Of course me, I just post an article without finishing my sentences.

Andy C points out 7 habits of highly ineffectual bloggers including (automatically) playing music, crazy Flash animation (let’s face it folks, Flash animation is just animated GIFs grown up) and pleading for comments.

Rod Boothby of Innovation Creators points out an interesting survey asking What’s the Biggest Lie About Blogging? The most interesting response, as Rod points out, comes from Seth Godin:

Oh for sure, it’s this: That people care what you say. They don’t. They care what they get.

I think both articles bring up good points for aspiring bloggers. Don’t think they’re right? Take a look at the most popular stories and the most popular blogs. Do what you want with your blog, but both these posts point out some of the pitfalls best avoided, or at least used sparingly if you’re trying to build traffic to a blog.

blog, blogging

« Previous PageNext Page »