Reputation: 4028
I am trying to add a day to a date retrieved as below
//reading fromdatabase
Dim expenddt_ As String = rdr("Expected_End_Date").ToString
Dim dt_1 As Date = Date.Parse(expenddt_)
Dim expenddt As String = dt_1.ToShortDateString()
txtenddt.Text = expenddt
Suppose if expenddt_
the value comes as "11/1/2012 12:00:00 AM", than dt_1
has the value #11/1/2012# and expenddt
has "11/1/2012" so in textbox txtenddt
the value appears as expenddt
.
Now when i try to add a day to dt_1
as
Dim test As Date = dt_1.AddDays(+1)
Than the value in test comes as 11/2/2012, i.e a month gets added and not the day. How can i add a day?can anyone help me with this issue?
Upvotes: 2
Views: 23908
Reputation: 4028
Well, tahnk you guys . i parsed The date to mm//dd/yyyy format and than added a day to it. When i posted this question i was unable to parse the date to mm/dd/yyyy format. Now i did it and this question is solved.
Upvotes: 1
Reputation: 263683
here is a simple example:
Dim today As System.DateTime
Dim answer As System.DateTime
today = System.DateTime.Now
answer = today.AddDays(36)
Upvotes: 9
Reputation: 1881
I think your output format is MM/DD/YYYY, so you can try dt_1.ToString("dd/MM/yyyy") to see the content in the format you expected.
You can also check the Day property.
Upvotes: 0