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

adding hours + minutes with dateadd function

21
This is my first database in Access and I've been able to format and add date under 60 mins using the dateadd function... but I can't add dates OVER 1 hour like, 1:20, 1:25...etc...it just says type mismatch, and I can't find any solution to this problem, neither Microsoft or the web gives me any example of the Dateadd function when it comes to add hours + minutes ....

Expand|Select|Wrap|Line Numbers
  1. DateAdd("n", d, l)
Expand|Select|Wrap|Line Numbers
  1. DateAdd("H:N", d, l)
"n" = format any minute amount from 0 to 59 depending the case

"H:N" = format hours from 1 to 24 and from 0 to 59 minutes depending the case

d = 1:20(one hour and twenty minutes)(datepart) or 0:20(twenty minutes)(datepart)

l = The "actual" time (8:00 AM) (current time)



ex. Dateadd("n", "0:20", 8:00 AM)
Already did the example above (d = 0:20) in the program , It returns me 8:20 AM without a problem, but. the next one...

ex. Dateadd("H:N","1:20", 8:00 AM)

The above example should return "9:20 AM" but instead it returns syntax error, If I replace the "h:nn" to "n" it accepts the entry but assigns only "20" minutes, is this the correct way to format this?
Jun 29 '16 #1

✓ answered by zmbd

If you read the function description you should understand:
DateAdd Function - Syntax:
DateAdd ( interval, number, date ) (read me)


The only valid Interval settings are as given in the table in the above link. The string you are attempting to use is not one that is given; thus, the syntax error.

You must convert your desired interval to add (in this case 1 hour and 20 minutes) to one of the provided intervals (i.e. 80 minutes) and then execute the function.
DateAdd ("n",80,#20:00#)

-z

1 6259
zmbd
5,501 Expert Mod 4TB
If you read the function description you should understand:
DateAdd Function - Syntax:
DateAdd ( interval, number, date ) (read me)


The only valid Interval settings are as given in the table in the above link. The string you are attempting to use is not one that is given; thus, the syntax error.

You must convert your desired interval to add (in this case 1 hour and 20 minutes) to one of the provided intervals (i.e. 80 minutes) and then execute the function.
DateAdd ("n",80,#20:00#)

-z
Jun 29 '16 #2

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

Similar topics

3
by: Gabe | last post by:
Please see: http://www.showorders.com/test3.asp The code generating the page is as follows: testdate = "1/29/2003 1:00:00 PM" while count <> 5 testdate = dateadd("n",15,testdate)...
4
by: ey.markov | last post by:
Greetings, I have an A2K application where for a report the user enters a month-end date, and the system must gather transactions for that month. No problem, I thought, I'll just use the DateAdd...
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...
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...
4
by: rodrigo21 | last post by:
Hello, I have one form with a field for entering a date 'orderdate' and another field for entering a days interval 'range'. This form is used to preform a query on a travel tickets database, so...
6
by: Candy6 | last post by:
#include <iostream> #include <string> using namespace std; int main() { int seconds; int minutes; int hours;
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.