Dates in asp.net
-
Hi I want a numeric value to be added to the current date. the numeric value is provided dynamically. how do i do it? i tried the following but showing error : textbox1.text=now.date+textbox2.text i also tried : textbox1.text=now.date+val(textbox2.text) it is treating the + as concat operator and not as addition.
-
Hi I want a numeric value to be added to the current date. the numeric value is provided dynamically. how do i do it? i tried the following but showing error : textbox1.text=now.date+textbox2.text i also tried : textbox1.text=now.date+val(textbox2.text) it is treating the + as concat operator and not as addition.
AddDays method are provided there like:
DateTime tomorrow = DateTime.Today.AddDays( 1 )
Parwej Ahamad ahamad.parwej@gmail.com
-
Hi I want a numeric value to be added to the current date. the numeric value is provided dynamically. how do i do it? i tried the following but showing error : textbox1.text=now.date+textbox2.text i also tried : textbox1.text=now.date+val(textbox2.text) it is treating the + as concat operator and not as addition.
It depends on what you want to increase.
Now.AddDays
Now.AddSeconds
Now.AddHoursetc. Each of them asks for an integer value. so
DateTime.Now.AddDays(Convert.ToInt32(textbox2.text))
I hope this would solve your issue.Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->****
InfoBox Visual Studio 2010 Extension
Windows7 API Code Pack
Simplify Code Using NDepend** -
Hi I want a numeric value to be added to the current date. the numeric value is provided dynamically. how do i do it? i tried the following but showing error : textbox1.text=now.date+textbox2.text i also tried : textbox1.text=now.date+val(textbox2.text) it is treating the + as concat operator and not as addition.
ishwarya mahadevan wrote:
it is treating the + as concat operator and not as addition
That is you are working with text as a string, you need to convert the string to datetime inorder to add the number of days dynamically.