|
View previous topic :: View next topic
|
| Author |
Message |
Hari Inturi
New User
Joined: 29 Mar 2006 Posts: 4
|
|
|
|
I want to set month-end-dates for previous month and curren month in db2, Forexample, if the program is run on
March 11th, the processing date would be set to 2006-02-28. If the program
is run on March 17th, the processing date would be set to 2006-03-31. |
|
| Back to top |
|
 |
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
hi Hari Inturi,
you can set using this sql statement to previous month date
set fieldname=DATE(DAYS(CURRENT_DATE)-DAY(CURRENT_DATE))
thank's
thanooz. |
|
| Back to top |
|
 |
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
hi Hari Inturi,
you can set using this sql statement to current month date
set fieldname=LAST_DAY(CURRENT_DATE)
thank's
thanooz. |
|
| Back to top |
|
 |
Hari Inturi
New User
Joined: 29 Mar 2006 Posts: 4
|
|
|
|
My requirement is like this"Program AA3600 should set the processing date for rows with WORK_CT
equal to either 'PL DT' or to 'RW DT' based on the current date
that the program is executed on. Use the 15th
of the month as the trigger date. For example, if the program is run on
March 11th, the processing date would be set to 2006-02-28. If the program is run on March 17th, the processing date would be set to 2006-03-31?"
How can i set monthend-date with an db2 table?here work_ct is an column name of the table, PL DT and RW DT are rows?How can i set WORK_CT equal to monthend-dates with an PL DT?
Can u please write db2 code for this? |
|
| Back to top |
|
 |
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
hi Hari Inturi,
I am not geting please explain with example
Thank's
thanooz. |
|
| Back to top |
|
 |
Hari Inturi
New User
Joined: 29 Mar 2006 Posts: 4
|
|
|
|
ok, i will given complete description of of my problem
"As Is Now: Program WKPK069 reads the RSTOOK005 DB2 table and adds one month
to the processing date for rows with WORK_TC equal to either
'PL DT' or to 'RW DT'.
As Is Problem(s): There have been problems with dates being set
incorrectly, and the possibility exists that if the program is run more
than once during monthly processing, the resulting dates will be incorrect.
To Be: Program should set the processing date for rows with WORK_TC
equal to either 'PLDT' or to 'RW DT' based on the current date
that the program is executed on. So, no matter haw many times it may run
during the monthly processing, the date set will be correct. Use the 15th
of the month as the trigger date. For example, if the program is run on
March 11th, the processing date would be set to 2006-02-28. If the program
is run on March 17th, the processing date would be set to 2006-03-31." |
|
| Back to top |
|
 |
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
Firt you get the day from system
select day(current_date) into :hostvariable from sysibm.sysdummy1;
then write if condition,
If hostvariable <= 15
exec sql
update tablename
set fieldname=DATE(DAYS(CURRENT_DATE)-DAY(CURRENT_DATE))
wher condition
end-exec
else
exec sql
update tablename
set fieldname=LAST_DAY(CURRENT_DATE)
wher condition
end-exec
Thank's
thanooz. |
|
| Back to top |
|
 |
Hari Inturi
New User
Joined: 29 Mar 2006 Posts: 4
|
|
|
|
Hi Thanooz,
I will include this logic in my program.if it will work fine then no problem else i will ask u again.
Thanks for your Information.
Thanks
Hari |
|
| Back to top |
|
 |
thanooz
New User
Joined: 28 Jun 2005 Posts: 99
|
|
|
|
hi Hari Inturi,
If any problem came post to me.
thank's
thanooz. |
|
| Back to top |
|
 |
babu_hi
New User
Joined: 11 Apr 2006 Posts: 93
|
|
|
|
it's working fine.
Thanks
hari |
|
| Back to top |
|
 |
|
|