[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Remind User to change password.

Posted on 2009-02-13
Medium Priority
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

Accepted Solution

havj123 earned 2000 total points
ID: 23639898
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

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

(but TBH the solution from havj123 is cleaner and elegant)
		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

ID: 23647366
Thank u guys for ur help.

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

834 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