Helpful Information
 
 
Category: ASP Programming
Days left

Hello All,

I have the following. I want to give my users 10 days to access a part of my website. I also want to print the days a user has left in their 10 day subscription. I am using the Day(Now) function to insert 2 numeric values into 2 fields in my DB. A field called StartDate and a field named EndDate. Sometimes the EndDate is smaller than the start day which results in a negative number. Can someone point me in the right direction?

Here is what I am using

Start_Num = Day(Now)
End_Num = Day(Now) + 10

If End_Number > Start_Num Then
Total_Days = End_Num+31-Start_Num
Else
Total_Days = End_Num - Start_Num
End If

If Total_Days < 10 Then
Response.Write("You have" & " " & Total_Days & " " & "days remaining")
Else
Response.Write("Your Days are through")
End If

Try looking at the datediff and dateadd funtions, use full dates, that makes it much easier to calculate the number of days left










privacy (GDPR)