how can i know if there are a sundy between 2 dates?

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
fleurlisalu
Participant
Posts: 8
Joined: Thu Jul 19, 2007 6:10 am

how can i know if there are a sundy between 2 dates?

Post by fleurlisalu »

how can i know if there are a sundy between 2 dates? i have a condition for calculating a indicator, for exemple: date1=01/07/07 et date2=19/07/07, how can i know there are a sundy between date1 and date2? i have a table of "day" to know "what day is today?" how can i do it? my english is terrible, i am sorry :oops:
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Welcome aboard! You need to calculate if the difference in dates is greater than 6, or if less than 6 the day of the week of the starting date plus the difference will include a Sunday. Any date separation greater than 6 must mean that one of the dates is a Sunday or that the number of days is greater than a week and therefore includes Sundays.

The simple algorithm is:

StartDate.DayOfWeek + (EndDate - StartDate) > 6

If 2007-01-01 is a Monday, and Monday is day of week #1 then:

1 + (2007-01-07 - 2007-01-01) = 7 (must have included a Sunday)

1 + (2007-01-04 - 2007-01-01) = 4 (could not have included a Sunday)

4 + (2007-01-04 - 2007-01-04) = 4 (could not have included a Sunday)

4 + (2007-01-07 - 2007-01-04) = 7 (must have included a Sunday)

4 + (2007-01-07 - 2007-01-04) = 7 (must have included a Sunday)

6 + (2007-01-07 - 2007-01-06) = 7 (must have included a Sunday)

1 + (2007-01-23 - 2007-01-01) = 23 (must have included a Sunday)
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
fleurlisalu
Participant
Posts: 8
Joined: Thu Jul 19, 2007 6:10 am

Post by fleurlisalu »

thank you so much, i will test it, :lol:
Post Reply