473,320 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

DateDiff Function

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
Sep 21 '07 #1
1 1217
ck9663
2,878 Expert 2GB
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
Sep 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: News Central | last post by:
To all! I use the DateDiff function using VB6 and get this error 'Wrong number of argument or invalid property assignment' ... have anyone seen this problem? thanks ....
7
by: Drago | last post by:
Hi, I got the next question, I want to know the diference between two dates and thats is really easy, but my problem is get that diference in the following format ex. "the diference is= 0 year,...
6
by: Lofty | last post by:
Hi all. I have to write an app that interacts with mySQL (I really must have done some evil, evil stuff in a previous life to be landed with this!) I need to work out the difference in days...
1
by: intl04 | last post by:
I'm trying to set up a query that will include a new field ('Days until completion') whose value is derived from the DateDiff function. I think I have the syntax correct but am not sure. Days...
4
by: Paolo | last post by:
I am having some problem with a Year Function. I have form on which I have 4 field which indicate dates and an additional form which sums those dates: These are the fields: YEARS...
1
by: PMBragg | last post by:
ORINGINAL Post >Thank you in advance. I'm trying to pull all inventory items from December >of the previous year back to 4 years for my accountant. I know this can be >done, but I'm drawing a...
5
by: mcbill20 | last post by:
Hello all. I have a really basic question that I hope someone has a better answer for. I apologize in advance-- I know this is probably a really basic question but I am used to Oracle rathern than...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
6
by: kevinjwilson | last post by:
I am trying to get the date difference between two dates but I don't want the function to include weekends in the calculation. Does anyone have an idea on how to make this work?
2
by: muddasirmunir | last post by:
i am using vb 6 , i had place two datepicker in form now i want to calcuate differcen of month in two date for this i used the function datediff i had try it withh many syntax but getting error...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.