0

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!

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by sanjaycedti
0

Hi There

You can try this code
Note : RegisterDate is your actual date from table

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

          If CheckIsValidUser() = False Then
            Label1.Text = "Your Status is INACTIVE"
        Else
            Label1.Text = "Your Status is ACTIVE"
        End If
    End Sub

Private Function CheckIsValidUser() As Boolean
        '
        Dim RegisterDate As Date = Microsoft.VisualBasic.DateAdd(DateInterval.Month, -1, Date.Today).ToString
        Dim ExpiryDate As String = Microsoft.VisualBasic.DateAdd(DateInterval.Month, 1, RegisterDate).ToString
        If ExpiryDate.ToString = Date.Today.ToString Then
            ''Raise your exception
            Return False
        Else
            Return True
        End If



    End Function

Mark as solved if it helps you!!!

Edited by reach_yousuf: n/a

0

try this this would work-

DateTime validTillDate = registrationDate.AddMonths(1);
        if (DateTime.Compare(DateTime.Now, validTillDate) < 0)
        {
            //Active
        }
        else
        {
            //Inactive
        }

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.