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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datediff

Status
Not open for further replies.

cjkenworthy

Programmer
Joined
Sep 13, 2002
Messages
237
Location
GB
I want to calculate the difference between two dates using the following code:

dim cancel_date, date_now, difference
cancel_date = NGN.Fields.Item("date_held").Value
date_now = Date()

difference = DateDiff("d", cancel_sale, date_now)

if difference > 7 then
response.write("Yes")
else
response.write("No")
end if

Problem is, given

'cancel_date' has a value of 09/12/02
'date_now' has a value of 11/12/02

difference is '37601' for some strange reason.

Any ideas?
 
you have them backwards.
don't feel bad I used to do it all the time
try

difference = DateDiff("d", date_now,cancel_sale)
you also don't need the var declaration for now. just use now in the datediff function

Just a suggestion: faq183-874
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top