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.

Recommended Answers

All 3 Replies

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)

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.

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,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.