Tuesday, May 27, 2008

SQL date manipulating in Oracle

Today I wrote a script that would take the values I had from my Calendar table, which contained all months with their start date and end date for the year of 2008, and insert them back for the year of 2007. My first solution didn't work so well and threw an error. I came to learn that the TO_YMINTERVAL function doesn't work because it doesn't handle leap year.
The function that did the job right was ADD_MONTH.
Here goes my script:

INSERT INTO calendar
(calendar_id,
month,
full_month,
begin_date,
end_date)
SELECT calendar_s1.nextval,
month,
full_month,
add_months(begin_date,-12),
add_months(end_date,-12)
FROM calendar;

Try that out and let me know if you have other simpler solutions for a similar problem.

Wednesday, May 14, 2008

Introduction

Dear readers,
The purpose of this blog is to provide information, definitions, and ways of doing stuff with technology, mostly with programming, database, setting up different types of server - such as normal proxy servers, transparent proxy servers, web servers, etc...
The main purpose of this blog is really to keep my notes online so I can reference to them later on, if I go through the same problem.
I also want to go over some basic programming and database concepts to help beginners dive in programming without fear.
Let me know if you have any questions.

A brief introduction about me.
My name is Mathew Pretel. I work at Corda Technologies currently as a developer while going to school at BYU-Idaho. My major is Computer Information Technology with emphasis in development.
I'm married and we have a 6 months old little girl.