|
-
Aug 6th, 2009, 05:28 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] date difference
Hi guys, I need help about date differences. See we have a link that I want to expire it after 3 months. So if the user goes to that link, it will say it's expired.
I don't know what is the logic behind it to identify the date that saved in the database and compare it to today's date. If today's date is greater than the date in the db 3 months and more, then the link is expired. Or the year is greater than the year in the db, link expired.
-
Aug 6th, 2009, 07:08 PM
#2
Lively Member
Re: date difference
what you can do is something like this:
vb Code:
Dim Today as datetime = system.datetime.now Dim ExpDate as datetime ExpDate = Today.addmonths(3)
I just typed this out and did not check syntax... This will make the ExpDate 3 months from now
Then you can check
vb Code:
If ExpDate > datetime.now then 'Expired else 'Do whatever you need End If
Last edited by mjcoco01; Aug 6th, 2009 at 07:14 PM.
-
Aug 7th, 2009, 01:46 AM
#3
Re: date difference
When user visits the link, call the database, (you'll undoubtedly have the ID), get all the details that you need out. For example, if it's an article, get the title, body, keywords, published date, etc. out.
Convert the published date to a DateTime. Then compare.
Code:
If DateTime.Now.AddMonths(3) >= publishedDate Then
Response.StatusCode = 410
Response.Status = "Expired"
LabelMessage.Text = "This article no longer exists."
End If
(Something like that, don't copy paste it)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|