Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Basically, i have a database and im creating an insert method in c# that inserts a record into a member table

I have inserted the firstname, surname, email address etc but i want to insert an expiry date

Now i want it so its 3 years from the day they registered.

Is there a way to do this?

as simple as you possibly can, im a very very big newbie.
Posted

1 solution

There are some good Date/Time examples at http://www.dotnetperls.com/datetime[^]

For your case, you can do:

C#
DateTime expiryDate = DateTime.Today.AddYears(3);


And then add expiryDate to your sql that saves it into the table.
 
Share this answer
 
Comments
[no name] 18-Feb-14 20:37pm    
You're a genius, the most simplest thing ever!!! haha was expecting some complex sh*t to be posted, but man you seriously just saved me hours and hours haha.. thanks mate, helps sooo much :)
5*
ZurdoDev 18-Feb-14 21:14pm    
Let intellisense teach you. :)
Sergey Alexandrovich Kryukov 18-Feb-14 21:15pm    
Amazing level of OP satisfaction... :-)
5ed... :-)
—SA
thatraja 19-Feb-14 2:20am    
5!
Andrius Leonavicius 19-Feb-14 16:27pm    
+5P.S. OP's comment improved my mood. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900