Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I just want to say how much I value your site. I hope the good work keeps up there. It's really helped me..."

Geography

Where in the world do Tek-Tips members come from?
Bobje (Programmer)
3 Jul 07 11:12
Hello,
a question on coding. We deliver orders to stores and want to measure the delay between the order and the delivery. we have three timestamps: order, scan at warehouse and scan at store.
we need to know the delay between all steps.
All stores have one or more closingdays, the warehouse is closed on weekends, there are public holidays,...

so we need to calculate the 'permitted delay'. If order is placed on saturday we have a permitted delay of 2days, if the  store that made the order is closed on monday one day should be added.

in case this monday is a public holiday the foreseen delay shouldn't be counted twice of course.
Any ideas on how I could get this in pl/sql procedure?
Hans63 (Programmer)
4 Jul 07 2:55
I would build a table based on the calendar, with all kinds of attributes (weekday, workday, public holiday, name of day, nr of day in the year, etc). Just like the way I would build a date dimension, but this time it includes an attribute to identify a warehouse, store, etc. With this information, building an SQL statement to find out any kind of delay becomes very easy.

It comes down to finding the first day the warehouse is open (use of MIN(date) where workday='Y') and then it is just counting the number of days between sysdate and the just found date.
Bobje (Programmer)
5 Jul 07 11:13
To keep it simple, we have three tables: order, holidays and stores

order:
id |Store  | OrderDate | scan@WarehouseDate | Scan@StoreDate
1  |123    | 01/01/2007| 02/01/2007         | 04/01/2007

holidays:
Date          | Country | Quantity
01/01/2007| Es      | 1

Stores
Store |Mo |Tu |We |Th |Fr |Sa |Su
123    |1  |1  |0  |1  |1  |1  |0

1 means store is open that they, 0 means it was closed.

So now I'd like to know whether order 1 was in time at kp.
It was scanned only one day after the order, but as the order was placed on a holiday this is ok, we get a permitted delay of 1 for this.
Then it was scanned only two days later at the store. But 3/1/2007 was a wednesday and the wednesday the store isn't open so we have a permitted delay of 1 for this as well.

Now I need the table delay filled
order delay
orderid | PermDelayHub |PermDelayStore |DelayHub |DelayStore
1          | 1                   |1                       |1               |2

and this with some (pl/)sql

Thanks
johnherman (MIS)
9 Jul 07 16:03
I would create a routine to check the "Days between" two selected dates which also checks the company calendar to ignore (subtract from) selected dates.

Your idea to populate a "1" for a working day and "0" for non-working day would also allow you to sum that value from BeginDate to EndDate.

-------------------------
The trouble with doing something right the first time is that nobody appreciates how difficult it was - Steven Wright

Bobje (Programmer)
11 Jul 07 3:21
thanks, that's what I've done in the mean time and performance is ok.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close