View previous topic :: View next topic
|
Author |
Message |
kimmybunn
New User
Joined: 19 Nov 2008 Posts: 3 Location: India
|
|
|
|
Doubt to write a SQL:
I am having a table,with different fields such as date,week_end ,month_end,year_end etc
depends on the date I need to update the flags of the reamaining fields
eg: if date is 30/12/2010
week_end(last working day of the week) ='Y'
month_end(last working day of month) ='Y'
year_end (last working day of year) ='Y'
This date always varies and depends on this date I need to set the flags to the remaining fields
As I know only the basics of DB2,please anyone give me the complete SQL for the above mentioned scenario
Thanks in advance
Kimmy |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Kimmy and welcome to the forum,
This does not appear to be something to handled by a simple sql query.
Somehow, all of the business rules surrounding calendar processing for your organization need to be considered. For example, what it the last day of a month is on Monday, but that is a holiday? |
|
Back to top |
|
|
kimmybunn
New User
Joined: 19 Nov 2008 Posts: 3 Location: India
|
|
|
|
Hi Thanks alot for the reply.
Yes whatever you said is correct.Last working day(Shouldnt be a bank holiday).If last day of month is a bank holiday then the last working day is Friday.
I have gone through some of the old postings.Is it possible to use case staement or a procedure for doing the same
Expecting valuable informations from experts
Thanks
Kimmy |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
calendars are a murky issue, that should not be solved by individuals,
but at organization level providing the proper tools and standards
( standards at least )
You better speak with somebody higher in Your organization
in all the organization I worked in, there was such an approach
and yearly according to the organization product life cycle and to the legal issues
all the relevant calendar management routines were reviewed |
|
Back to top |
|
|
kimmybunn
New User
Joined: 19 Nov 2008 Posts: 3 Location: India
|
|
|
|
OK thanks for the information.
But from my knowledge,dayofweek function is available in db2 (eg:dayofweek('18/01/2008')and with this I can get the numeric values such as 1, 2, ...7.using this value I can update the table for the field 'week_end' rite?
For the time being I can hardcode the bank holidays for this 2008 year.
Is it a good idea to implement
Please advise |
|
Back to top |
|
|
|