I am a new bee for programming, my question may be simple but i dont know how to do it...My senario is I have four column named DISCOUNT CODE, DATE ACTIVATED, DATE DEAVTIVATE, IS ACTIVE... So when i use the DISCOUNT CODE the DATE ACTIVATED should be todays date and the DATE DEACTIVATE should be exactly one year from the date activated...and in the IS ACTIVE column the value should be 1 untill the code is active...and after one year the value should be 0...
could some pls guide me how to write a stored procedure for this...Thanks in advance..
Regards,
Rahul
Quote:
Originally Posted by mibbsin
Hi all !!!!
I am a new bee for programming, my question may be simple but i dont know how to do it...My senario is I have four column named DISCOUNT CODE, DATE ACTIVATED, DATE DEAVTIVATE, IS ACTIVE... So when i use the DISCOUNT CODE the DATE ACTIVATED should be todays date and the DATE DEACTIVATE should be exactly one year from the date activated...and in the IS ACTIVE column the value should be 1 untill the code is active...and after one year the value should be 0...
could some pls guide me how to write a stored procedure for this...Thanks in advance..
Regards,
Rahul
if you're inserting into a table
insert into DISCOUNTTABLE (DISCOUNT CODE, DATE ACTIVATED, DATE DEAVTIVATE, IS ACTIVE) values (newdiscountcode, getdate(), dateadd(yy,1, getdate(), 1)...
now, you need a batch to run every 12MN to:
UPDATE DISCOUNTTABLE
set ISACTIVE = 0
where DATE DEAVTIVATE = getdate()
this code was not checked..it's more a pseudocode than anything...but i hope you got the idea
No comments:
Post a Comment