Remind User to change password.

Posted on 2009-02-13
Last Modified: 2012-05-06
I am using SQL2005 n .Net 3.5

I have a field in my table as Updatedate which contain last update date of the password.

Now I want to force user to change his password after 60 days.Before this,I want to remind him for the password change from 54th day.

6 days left.
55th day 5 days left
60 th day.0 days left and now you have to change the password.

Can we write any stored procedure for such functionalily?

Thank you
Question by:rajputamitd
    LVL 6

    Accepted Solution

    Either try this in code behind.
    Just take the date value from updatedate field. Take days from the Date. Subtract it from Current date.

    Then check it the number of days is greater than 53.
    if(dt >53)
         int days = 60 - dt;
         label1.text = days + "days left";
    LVL 25

    Expert Comment

    If you need the calculation within SQL, you can use something like the following -

    (but TBH the solution from havj123 is cleaner and elegant)
    SELECT	CASE	WHEN DATEDIFF(day,Updatedate,GETDATE()) > 60
    		THEN '0 days left for password change, cannot proceed!'
    		WHEN DATEDIFF(day,Updatedate, GETDATE()) > 53
    		THEN CAST(60 - DATEDIFF(day, Updatedate, GETDATE()) AS varchar(1)) + ' days left for password change'
    		ELSE ''
    	AS AlertMessage
    WHERE UserID = @userId

    Open in new window


    Author Comment

    Thank u guys for ur help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
    by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now