Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Months 2

Status
Not open for further replies.

dtfrancis15

IS-IT--Management
May 16, 2001
7
GB
I pass the variable "Months" from page 1 to 2, and then using the following set dtDate as today and dtThen as the date 3, 6, 12 or 18 months prior as set by Months.

How do I set this as a useable variable for the following reports?? How do I use "Months" in place of -2 in the formula.



Dim dtDate, strDate
dtDate = Now()
strDate = Year(dtDate) & Right("00" & Month(dtDate), 2) & Right("00" & Day(dtDate), 2)

dim dtThen
dtThen = Now()
Response.Write DateAdd("m", -"3", dtNow)
 
You seem to be using lots of different date variables - dtDate, strDate, dtThen, dtNow and there is no mention of -2 in anything you have so I am not really sure what you are referring to.

But if you want to subtract the value of months from the current date, then you can do something like:

dtNow = date()
dtThen = DateAdd("m", "-" & Request.Form("Months"), dtNow) Mise Le Meas,

Mighty :)
 
dtDate is todays date
strDate is todays date in a different format
dtThen is the date x months previous
strDateThen is the date x months previous in different format.


dtThen = DateAdd("m", "-" & Request.Form("Months"), dtNow)

This reports an error because of "-" part. is this how it is meant to be entered?
 
Are you using the POST method to pass the Months variable to the second page. If you are not, then try:

dtThen = DateAdd("m", "-" & Request.Querystring("Months"), dtNow)

If you are using POST, try:

Months = "-" & trim(Request.Form("Months"))
dtThen = DateAdd("m", Months, dtNow)

Mise Le Meas,

Mighty :)
 
This is the error I get - swears blind the "-" is at fault:

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "-"]'
/datawhsesample/Service/Contracts/InActive/teamcontracts.asp, line 45
 
Sorry, my mistake.

Try the following:

Months = 0 - CInt(Request.Form("Months"))
dtThen = DateAdd("m", Months, dtNow)

Mise Le Meas,

Mighty :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top