0

How would I increment Date with a value from a database.

Example: Date + Database Field value (random values)

(08/01/2011 + 5 = 08/06/2011)

Thanks in advance.

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
1

Try it this way:

Dim days As Integer = 12 'your value from DB! (one or the other - didnt know what you want
Dim months As Integer = 5 'your value from DB!
Dim [date] As DateTime = DateTime.Now 'some date !

'get new date (current date + days):
[date] = [date].AddDays(days)

'get new date (current date + months):
[date] = [date].AddMonths(months)
0

Try it this way:

Dim days As Integer = 12 'your value from DB! (one or the other - didnt know what you want
Dim months As Integer = 5 'your value from DB!
Dim [date] As DateTime = DateTime.Now 'some date !

'get new date (current date + days):
[date] = [date].AddDays(days)

'get new date (current date + months):
[date] = [date].AddMonths(months)

Great~ That exampled helped me form something a little bit different that worked.

0

Great. If this is it, you can complete the thread with setting it as answered.
If not, you can still ask questions ,regarding the thread`s topic.
Best regards,

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.