This topic is locked

Calculating Date that Is 30 Days from Another Date

2/4/2007 12:42:34 AM
ASPRunnerPro General questions
BeachyLife author

I have two date fields: StartDt and ExpDt. When the user enters a date in the StartDt field, I would like to automatically calculate 30 days from that date and store it in the Expdt. How do I do this? Is it using the BeforeAdd and BeforeEdit events? I'm new at this so any suggestions would be appreciated.
Example:

User enters 02/02/2007 as StartDt. Sytem calculates and stores 03/04/2007 as Expdt.

Sergey Kornilov admin 2/5/2007
BeachyLife author 2/7/2007

This tutorial can help:

http://www.asptutorial.info/sscript/Addtimeperiodtodate.asp



What exactly should I code in the BeforeAdd and BeforeUpdate events? Thanks for your help.

J
Jane 2/7/2007

Here is a sample code. No guarantee it works.

str2 = "select DateAdd('d',30,'"&dict("StartDt")&"') from " & strTablename

Set rsTemp2 = server.CreateObject("ADODB.Recordset")

rsTemp2. open str2,dbConnection
dict("ExpDt") = rsTemp2(0)
rsTemp2. Close : set rsTemp2 = Nothing