473,395 Members | 1,443 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,395 software developers and data experts.

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.

2 39459
colintis
255 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
Thanks..worked out for me..
Oct 26 '10 #3

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

Similar topics

2
by: Steevo | last post by:
Is there a way of producing a script to automatically update and show: "Updated x hours and x minutes ago on xx/xx/xx" I currently have a script to automatically show the date and time the page...
18
by: Tim Quon | last post by:
Hi I need to print the current time. I found an example where this is done as followed: long *mytime; time(mytime); printf("time: %s", ascitime(mytime); But this doesn't work and prints...
7
by: Stu | last post by:
Is there a simple function call within "C" that I can use to convert number of seconds (keep in mind this may be a type longlong and has to work on UNIX and NT) into Days, months, Hours, Minutes...
2
by: J M | last post by:
I rebooted a network device just few minutes ago and getting device-up-time value 3191. How do I convert a time elapsed in days hours minutes and seconds for above value? Example: This device...
6
by: Tim | last post by:
How can I tell if 24 hours has past from now? Thanks! Tim
7
by: Takeadoe | last post by:
Good evening, One more and I'm done - I promise. I have 3 variables - (hours, minutes, and am or pm - 1 and 2, respectively). Is there some way that I can combine these 3 into a single...
1
by: baneaic | last post by:
I'm trying to create a form that will allow a user to enter certain job specifications (# of pages and # of copies) and then have a field that will automatically calculate how long that job will...
12
by: remya1000 | last post by:
how can i select time (hours,minutes,second) in updown arrow buttons in VB.NET. as we have current time displayed in date and time properties in our system. in date and time properties, while...
2
by: mar10 | last post by:
i have TIME WORKED stored as minutes - I'd like to convert this to days,hours,minutes. I'm currently converting to hours and minutes but have not had success adding the days portion to the...
6
by: Candy6 | last post by:
#include <iostream> #include <string> using namespace std; int main() { int seconds; int minutes; int hours;
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.