By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,290 Members | 1,263 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,290 IT Pros & Developers. It's quick & easy.

setting date 2 to be 365 days later than date1

P: n/a
Hi

I have done a program that is to work out travel insurance for single and
annual trips. For single trips I put in a start and end date no problems.
But for an annual trip I only need to insert the start date of the cover and
I want the program to automatically work out when the last day of the cover
is and make that non editable. I have an idea how to do this, but how do I
go about coding this part to do this automatically???

Regards

Scott
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You can use something like this:

Dim Date1 As DateTime = DateTime.Now
Dim Date2 As DateTime = Date1.AddDays(365)

Nov 21 '05 #2

P: n/a
Scott,
As Chris suggests you can use DateTime.AddDays to add a number of days to a
date.

There is also DateTime.AddYears and DateTime.AddMonths that you may find
useful.

Dim Date1 As DateTime = DateTime.Now
Dim Date2 As DateTime = Date1.AddYears(1)
Dim Date3 As DateTime = Date1.AddMonths(12)

For the complete list of methods that DateTime objects (values) support see:

http://msdn.microsoft.com/library/de...mberstopic.asp

On a form if I did not want the user to change the second Date value, I
would make the control read only (see the Enabled property).

Hope this helps
Jay

"Scott" <sj*****@btinternet.com> wrote in message
news:JE*************@newsfe2-gui.ntli.net...
Hi

I have done a program that is to work out travel insurance for single and
annual trips. For single trips I put in a start and end date no problems.
But for an annual trip I only need to insert the start date of the cover
and I want the program to automatically work out when the last day of the
cover is and make that non editable. I have an idea how to do this, but
how do I go about coding this part to do this automatically???

Regards

Scott

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.