944,166 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 842
  • ASP.NET RSS
Oct 11th, 2009
0

check date

Expand Post »
Hi to all,

I am developing asp.net website using VB.
In my website user registerd to access facilities but I want to give that authority for 1 month only. after 1 month user has to renew his account.
I am inserting date when he registerd in our site.
But the problem is how to find one month later date..?
let us consider one user is registerd on 12/8/2009 & I want to give message that your status will be inactive on 12/9/2009.

How to do that..?
Plz help!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
sakhi kul is offline Offline
62 posts
since Aug 2009
Oct 12th, 2009
0
Re: check date
Hi There

You can try this code
Note : RegisterDate is your actual date from table
ASP.NET Syntax (Toggle Plain Text)
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.  
  3. If CheckIsValidUser() = False Then
  4. Label1.Text = "Your Status is INACTIVE"
  5. Else
  6. Label1.Text = "Your Status is ACTIVE"
  7. End If
  8. End Sub
  9.  
  10. Private Function CheckIsValidUser() As Boolean
  11. '
  12. Dim RegisterDate As Date = Microsoft.VisualBasic.DateAdd(DateInterval.Month, -1, Date.Today).ToString
  13. Dim ExpiryDate As String = Microsoft.VisualBasic.DateAdd(DateInterval.Month, 1, RegisterDate).ToString
  14. If ExpiryDate.ToString = Date.Today.ToString Then
  15. ''Raise your exception
  16. Return False
  17. Else
  18. Return True
  19. End If
  20.  
  21.  
  22.  
  23. End Function
  24.  
Mark as solved if it helps you!!!
Last edited by reach_yousuf; Oct 12th, 2009 at 3:49 am.
Reputation Points: 12
Solved Threads: 38
Junior Poster
reach_yousuf is offline Offline
194 posts
since Sep 2007
Oct 25th, 2009
0

Thanks a LOT

Thanks
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
sakhi kul is offline Offline
62 posts
since Aug 2009
Oct 27th, 2009
0
Re: check date
try this this would work-
ASP.NET Syntax (Toggle Plain Text)
  1. DateTime validTillDate = registrationDate.AddMonths(1);
  2. if (DateTime.Compare(DateTime.Now, validTillDate) < 0)
  3. {
  4. //Active
  5. }
  6. else
  7. {
  8. //Inactive
  9. }
Last edited by peter_budo; Oct 27th, 2009 at 10:49 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sanjaycedti is offline Offline
3 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: chat room in asp.net
Next Thread in ASP.NET Forum Timeline: Custom HttpHandler.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC