15,964,307 members
See more:
I have a Table Which have 4 Columns.
Table Name- Personnel Details
Fields- Name, Position, Commence Date and Expiry Date.
What I want to make is before 1 month date for expiration which is based on Expiry Date there will be notice or pop up message "To be renew". I don't know how to calculate the date. Thanks..
Posted
Updated 12-Jun-22 6:45am
Richard MacCutchan 18-Feb-14 10:36am
TimeSpan t = ExpiryDate - DateTime.Now;
if (t.days < 32)
send the message ...
Member 12628849 20-Aug-16 3:48am
FFF
Member 12628849 20-Aug-16 7:47am
I want to make is before 1 month date for expiration which is based on Expiry Date there will be notice or pop up message "To be renew". I don't know how to calculate the date

## Solution 1

As long as Expiry Date is a DateTime object, you should have relatively little trouble. Now, I'm assuming here that you are applying this at the client side, seeing that you haven't included SQL Server or other database in your tags, I'm not going to cover doing this as a query and I'm assuming that you have retrieved this data already. Suppose you mapped Expiry Date into a C# property called ExpiryDate, then all you need to do is:
C#
bool shouldRenew = ExpiryDate.AddMonths(-1) > DateTime.Now;

Sergey Alexandrovich Kryukov 18-Feb-14 14:46pm
Sure, a 5.
—SA
Member 12628849 20-Aug-16 7:45am
i want to alert before one months date of expiry

## Solution 2

This can be achieved by date difference.
See a very good article[^] is given there.

or rather,
C#
DateTime x1 = DateTime.ParseExact("20119", "yyyyM", CultureInfo.InvariantCulture);
DateTime x2 = DateTime.ParseExact("20135", "yyyyM", CultureInfo.InvariantCulture);

int months =  Math.Abs((x2.Month - x1.Month) + 12 * (x2.Year - x1.Year));

-KR