check date

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2009
Posts: 31
Reputation: sakhi kul is an unknown quantity at this point 
Solved Threads: 0
sakhi kul sakhi kul is offline Offline
Light Poster

check date

 
0
  #1
Oct 11th, 2009
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!
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 66
Reputation: reach_yousuf is an unknown quantity at this point 
Solved Threads: 12
reach_yousuf reach_yousuf is offline Offline
Junior Poster in Training
 
0
  #2
Oct 12th, 2009
Hi There

You can try this code
Note : RegisterDate is your actual date from table
  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.
Yousuf
Software Developer
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 31
Reputation: sakhi kul is an unknown quantity at this point 
Solved Threads: 0
sakhi kul sakhi kul is offline Offline
Light Poster

Thanks a LOT

 
0
  #3
31 Days Ago
Thanks
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 3
Reputation: sanjaycedti is an unknown quantity at this point 
Solved Threads: 0
sanjaycedti sanjaycedti is offline Offline
Newbie Poster
 
0
  #4
29 Days Ago
try this this would work-
  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; 29 Days Ago at 10:49 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC