If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > process data containing start and enddates

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-24-03, 05:31
blom0344 blom0344 is offline
Registered User
 
Join Date: Jan 2003
Location: Zutphen,Netherlands
Posts: 256
process data containing start and enddates

I am trying to process data coming from an absence database. Basically the only input is a file with 3 fields: Employeenumber,startdate, enddate.

The requirement is to calculate somehow:

1. The number of days between the the dates (easy)
2. The number of days for each month, generating a child record for each month with the number of days, like:

Input:

TBL 11-19-2003 01-26-2004

Output:

Master-record:

TBL 11-19-2003 69

Children:

TBL 11-19-2003 2003 NOV 12
TBL 11-19-2003 2003 DEC 31
TBL 11-19-2003 2004 JAN 26

I do not see a solution with just SQL , but would a stored prodecure be able to handle such (seeming simple) problem?
__________________
Ties Blom
Senior Application Developer BI
Getronics Healthcare
DB2,ORACLE,Powercenter,BusObj,Access,
SQL, SQL server
Reply With Quote
  #2 (permalink)  
Old 12-29-03, 05:33
jsander jsander is offline
Registered User
 
Join Date: Apr 2003
Posts: 191
Re: process data containing start and enddates

Hi,

did you consider using a support table like this:

YEAR MONTH DAYS
...
2003 1 31
2003 2 28
2003 3 31
2003 4 30
...
2003 12 31
...

I believe this would enable you to do a couple of joins and do the days calculations.

Next I would try and create a table function like shown above.

Johann

Quote:
Originally posted by blom0344
I am trying to process data coming from an absence database. Basically the only input is a file with 3 fields: Employeenumber,startdate, enddate.

The requirement is to calculate somehow:

1. The number of days between the the dates (easy)
2. The number of days for each month, generating a child record for each month with the number of days, like:2

Input:

TBL 11-19-2003 01-26-2004

Output:

Master-record:

TBL 11-19-2003 69

Children:

TBL 11-19-2003 2003 NOV 12
TBL 11-19-2003 2003 DEC 31
TBL 11-19-2003 2004 JAN 26

I do not see a solution with just SQL , but would a stored prodecure be able to handle such (seeming simple) problem?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On