Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Hours to DateTime

Status
Not open for further replies.

Bodhi147

MIS
Jan 24, 2003
17
US
I am trying to add hours to a datetime. Not sure what the best way to do this is. If I have 60 hrs (2.5days) and want to add that to todays date 10/25/2005 11:35:00 AM. I need the outcome to calculate not only the days but to add the half day to the time.

Thanks for the help
 
How about using the AddHours method?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
AddHours gives me 10/27/2005 11:35:00 AM, it adds two days and forgets about the decimal. I need it to add .5 days to the time.
 
The AddHours function takes the number of hours as an argument so add 60 to it, not 2.5. e.g.
Code:
Dim dt as DateTime = System.DateTime.Now
Response.Write(dt.AddHours(60))


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top