473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

DateTime.AddHours method doesn't add anything


I am getting a DateTime value from a Calendar Control. It returns the date
at midnight. I want to add some hours to the value before I display it in a
text box.

C# back end to a web form - here's the code:
-------------------------------------------------------------------------------------
private DateTime startTime;

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
startTime = Calandar1.SelectedDate;
startTime.AddHours(8.5);
startDateTextBox.Text = startTime.ToString();
}
-------------------------------------------------------------------------------------

If I debug and step through the code, startTime gets set to the selected
data at 12:00:00 AM. The AddHours method does not change its value, it stays
at 12:00:00 AM.

--
Thanks!
Marty

Nov 23 '06 #1
3 7853

"radiolandog" <martykilroy at yahoowrote in message
news:EE**********************************@microsof t.com...
>
I am getting a DateTime value from a Calendar Control. It returns the
date
at midnight. I want to add some hours to the value before I display it in
a
text box.

C# back end to a web form - here's the code:
You are working in Dotnet. This group covers classic asp. Dotnet is
totally different and has its own group:
microsoft.public.dotnet.framework.aspnet.

--
Mike Brind
Nov 23 '06 #2

"radiolandog" <martykilroy at yahoowrote in message
news:EE**********************************@microsof t.com...
>
I am getting a DateTime value from a Calendar Control. It returns the
date
at midnight. I want to add some hours to the value before I display it in
a
text box.

C# back end to a web form - here's the code:
--------------------------------------------------------------------------
-----------
private DateTime startTime;

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
startTime = Calandar1.SelectedDate;
startTime.AddHours(8.5);
startDateTextBox.Text = startTime.ToString();
}
--------------------------------------------------------------------------
-----------
>
If I debug and step through the code, startTime gets set to the selected
data at 12:00:00 AM. The AddHours method does not change its value, it
stays
at 12:00:00 AM.
microsoft.public.dotnet.framework.aspnet

Would be a better group to ask, this group is for Classic ASP.

However try:-

startTime = startTime.AddHours(8.5);

>

Nov 23 '06 #3
Got it!

Thanks, Anthony Happy Thanksgiving.
--

Thanks!
Marty

"Anthony Jones" wrote:
>
"radiolandog" <martykilroy at yahoowrote in message
news:EE**********************************@microsof t.com...

I am getting a DateTime value from a Calendar Control. It returns the
date
at midnight. I want to add some hours to the value before I display it in
a
text box.

C# back end to a web form - here's the code:
--------------------------------------------------------------------------
-----------
private DateTime startTime;

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
startTime = Calandar1.SelectedDate;
startTime.AddHours(8.5);
startDateTextBox.Text = startTime.ToString();
}
--------------------------------------------------------------------------
-----------

If I debug and step through the code, startTime gets set to the selected
data at 12:00:00 AM. The AddHours method does not change its value, it
stays
at 12:00:00 AM.

microsoft.public.dotnet.framework.aspnet

Would be a better group to ask, this group is for Classic ASP.

However try:-

startTime = startTime.AddHours(8.5);



Nov 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: andrew lowe | last post by:
Hi, Please bear with me on this problem, first I'll give you some background: I have an object that contains a DateTime field which i pass to a webservice public class Foo { public DateTime...
13
by: bredal Jensen | last post by:
Hello gurus, I'm building a small booking system and i have come accross quiet a tedious pitfall. "I need to make sure that people do not book for tomorrow when todays time is greater or...
2
by: SenthilVel | last post by:
HI how to get the differences between 2 given dates?? supposse if i ahve 2 dates , DATEa, and current datetime. how can i find if the DATEa is less then 3 hrs from the current datetime ???...
1
by: bbdobuddy | last post by:
I want to be able to change a DateTime object from 12:00 AM to 12:00 PM and I am struggling in doing so. Any thoughts would be helpful
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
2
by: Paulers | last post by:
Hello Is it possible to create a DateTime structure that does not include the date? I am only intrested in the time and day. for example 23:00 Mon. I would eventually like to add and subtract...
11
by: Rubic | last post by:
I was a little surprised to recently discover that datetime has no method to input a string value. PEP 321 appears does not convey much information, but a timbot post from a couple years ago...
4
by: Mohan | last post by:
In the database, we are storing time in 3 columns: hours, Minutes and AM,PM. After retrieving it from the database, I want to load these values into a DateTime variable. I haven't had much...
4
by: sumip | last post by:
I just made a pretty strange observation with .NET 2.0 - DateTime.AddMilliseconds(double) and AddSeconds(double) seem to be broken: DateTime now = new DateTime(); DateTime t2 =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.