467,074 Members | 1,085 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,074 developers. It's quick & easy.

How to Add Hours and Minutes to current Time .

Rozeanna Jerry
Hi every one..I am trying to add 8 hours 15 minutes to current time and show the new time on a text box. How would I do that.?

For example if the current time is 8:00am then adding 8 hours 15 minutes should show 4:15pm.

Please help.

Anna
Oct 26 '10 #1

✓ answered by colintis

Using the function DateAdd will do the work, but the function only do one type of calculation at a time, so you can either convert the hours to minutes make a total add up, or use one DateAdd for hours, one for minutes.

Expand|Select|Wrap|Line Numbers
  1. Dim LDate As Date
  2.  
  3. LDate = DateAdd ("n", 495, Time())
"n" represent minutes, and 495 is adding 495 minutes (8hrs and 15mins) to Time(). But use Now() instead if you are adding time that pass 12 AM to another day.

  • viewed: 35051
Share:
2 Replies
100+
Using the function DateAdd will do the work, but the function only do one type of calculation at a time, so you can either convert the hours to minutes make a total add up, or use one DateAdd for hours, one for minutes.

Expand|Select|Wrap|Line Numbers
  1. Dim LDate As Date
  2.  
  3. LDate = DateAdd ("n", 495, Time())
"n" represent minutes, and 495 is adding 495 minutes (8hrs and 15mins) to Time(). But use Now() instead if you are adding time that pass 12 AM to another day.
Oct 26 '10 #2
Rozeanna Jerry
Thanks..worked out for me..
Oct 26 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

18 posts views Thread by Tim Quon | last post: by
6 posts views Thread by Tim | last post: by
1 post views Thread by baneaic@yahoo.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.