Hello,
This code returns today's date:
Dim next10days As Date = Date.Now
But how can I get the date for the 10th day from today?
Hello,
This code returns today's date:
Dim next10days As Date = Date.Now
But how can I get the date for the 10th day from today?
' Calculate what day of the week is 10 days from this instant.
Dim today As System.DateTime
Dim answer As System.DateTime
today = System.DateTime.Now
answer = today.AddDays(10)
System.Console.WriteLine("{0:dddd}", answer)
1. If you were to simply return the value:
//C#
return DateTime.Now.AddDays(10);
//VB
Return Date.Now.AddDays(10)
2. If you really just want a variable you can work with:
//C#
var MyDate10DaysFromNow = DateTime.Now.AddDays(10);
//VB
Dim MyDate10DaysFromNow as Date = Date.Now.AddDays(10)
Dim next10days As Date = Date.Now.AddDays(10)
Although, technically, it should be Date.Today
, not Date.Now
, because Now
also includes the time and you only want a date.