473,405 Members | 2,334 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,405 software developers and data experts.

How to subtract milliseconds (in text format) in a query?

547 512MB
I have a timing application. Now my clients want milliseconds accuracy added to it.
I have two fields called timestart and timefinish.
I manage to add milliseconds etc with a button from main form (RaceF) to subform (timesf) in the start field in a table (TimeT) using this:
Expand|Select|Wrap|Line Numbers
  1. timestart = Format(Now, "dd/MM/yyyy HH:nn:ss") & "." & Right(Format(Timer, "#0.00"), 2)
and when they finish:
Expand|Select|Wrap|Line Numbers
  1. timefinish= Format(Now, "dd/MM/yyyy HH:nn:ss") & "." & Right(Format(Timer, "#0.00"), 2)
this is what format looks like:
starttime
Expand|Select|Wrap|Line Numbers
  1. 27/02/2011 14:00:38.95
finishtime
Expand|Select|Wrap|Line Numbers
  1. 27/02/2011 14:32:05.51
In a query, how do i subtract these start and finishtimes, getting a result in this format HH:nn:ss:ms or 00:00:00:00
the final result will never be more than 12:00:00:00 (12hrs)
I have added a mini example of my application here.
please help i am stuck
Attached Files
File Type: zip millisecondsdb 2003.zip (27.6 KB, 138 views)
Feb 27 '11 #1

✓ answered by ADezii

@neelsfer - This will be fairly complicated, so I'll definitely need a little Time. The complexity, at least the way I see it, is having to subtract two TEXT Values which include Milliseconds, representing DATE/TIME Values, then return the Results in a precise Textual Format (hh:nn:ss:ii). Be patient, unless someone comes along with a better idea.

It is a couple of hours later, and I do believe that I have a workable solution. Click on the Timing Query Command Button and view the Results. I'll leave the Testing Phase up to you. See the Attached:

14 3815
ADezii
8,834 Expert 8TB
I see no easy way to accomplish this since both Time Values are TEXT, and contain a Millisecond Component. I'm assuming that all digits past the Period (.), 51, 92, 78, etc. represent Milliseconds, namely: 51 Milliseconds, 92 Milliseconds, and 78 Milliseconds respectively. Is this assumption correct?
Feb 27 '11 #2
neelsfer
547 512MB
Hi Mr Adezi. Yes i assume it is that. Can one not add it to a "date field" perhaps? I have tried with no success.
I came across this code on the internet. It was from a VB 6 website, and it somehow gives me a millisecond value - is required for a specific type of race in my application that is currently only in seconds. I just need to subtract the start and finish times in this instance.
Any other suggestions on how to add milliseconds to a "datefield" in access.
Feb 27 '11 #3
neelsfer
547 512MB
I have just taken out the date
Expand|Select|Wrap|Line Numbers
  1. timestart = Format(Time, "HH:nn:ss") & "." & Right(Format(Timer, "#0.00"), 2)
then i get this ie as starting time
Expand|Select|Wrap|Line Numbers
  1. 17:42:11.96
Feb 27 '11 #4
neelsfer
547 512MB
i got this code to generate ms but how to i link it to a button in form to create time in table
Expand|Select|Wrap|Line Numbers
  1. #
  2. Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
  3. #
  4. Private Type SYSTEMTIME
  5. #
  6.     wYear As Integer
  7. #
  8.     wMonth As Integer
  9. #
  10.     wDayOfWeek As Integer
  11. #
  12.     wDay As Integer
  13. #
  14.     wHour As Integer
  15. #
  16.     wMinute As Integer
  17. #
  18.     wSecond As Integer
  19. #
  20.     wMilliseconds As Integer
  21. #
  22. End Type
  23. #
  24. #
  25. #
  26. 'usage:
  27. #
  28. Dim MyTime As SYSTEMTIME
  29. #
  30.    GetLocalTime MyTime
  31.  
  32. Dim TimeText as String     
  33. #
  34.    TimeText = MyTime.wHour & ":" & MyTime.wMinute & ":" & MyTime.wSecond & "." & MyTime.wMilliseconds
  35.  
  36.    MsgBox TimeText 
Feb 27 '11 #5
ADezii
8,834 Expert 8TB
I got this code to generate ms but how to i link it to a button in form to create time in table
See the Revised Attachment, I think it says it all.
Attached Files
File Type: zip Millisecondsdb 2003_2.zip (34.1 KB, 113 views)
Feb 28 '11 #6
neelsfer
547 512MB
Thx Mr Adezi; It seems fine to me. Go for it pls
Feb 28 '11 #7
ADezii
8,834 Expert 8TB
@neelsfer:
Go for it pls
Not sure what you mean, kindly explain...
Feb 28 '11 #8
neelsfer
547 512MB
Sorry, i mean it looks 100% so far, as it adds MS.
Have you got an idea how one will subtract the 2 values?
Thx for your time. Appreciated
Feb 28 '11 #9
ADezii
8,834 Expert 8TB
I have an idea but I need to know exactly how you wish to display the Results, namely:
  • 1 min./25 secs./345 millisecs.
  • 2 hrs./14 mins./5 secs./13 millisecs.
  • 21.87 mins.
  • 00:00:23:234 (hh:mm:nn:ii)
  • etc.
Feb 28 '11 #10
neelsfer
547 512MB
The best way for me is 00:00:23:234 (hh:mm:nn:ii)
thx
Feb 28 '11 #11
ADezii
8,834 Expert 8TB
@neelsfer - This will be fairly complicated, so I'll definitely need a little Time. The complexity, at least the way I see it, is having to subtract two TEXT Values which include Milliseconds, representing DATE/TIME Values, then return the Results in a precise Textual Format (hh:nn:ss:ii). Be patient, unless someone comes along with a better idea.

It is a couple of hours later, and I do believe that I have a workable solution. Click on the Timing Query Command Button and view the Results. I'll leave the Testing Phase up to you. See the Attached:
Attached Files
File Type: zip Millisecondsdb 2003_3.zip (35.3 KB, 118 views)
Feb 28 '11 #12
neelsfer
547 512MB
thx mr Adezi. I will test it. i appreciate your time and effort
Mar 1 '11 #13
neelsfer
547 512MB
i have started using the code in my application - works great!! Can't thank you enough Mr Adezi. Just have to add it to my reports, and then its finish!!.
Attached Images
File Type: jpg dhcapture1.jpg (70.4 KB, 203 views)
Mar 1 '11 #14
ADezii
8,834 Expert 8TB
Glad it all worked out for you, neelsfer.
Mar 1 '11 #15

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

Similar topics

14
by: Christophe Cerbourg | last post by:
hi, Bonjour, I'm using PHPMailer class to send mails and it works fine for HTML ones. But I can't manage to send correctly a text formatted mail... I tried this : - $message = "first...
3
by: tdeclercq | last post by:
HI, I want to be sure that users receive and can read my mails. How can I send mail in HTML AND text Format in one send ? thx
4
by: searider86 | last post by:
Does anyone know if there is a snippet of code that automatically removes the wrap text format in excel? I have an access form that displays data and allows the user to click on a cmdbutton to...
7
by: Eddy Soeparmin | last post by:
Hi, I need to display a DateTime field in 'mm/dd/yyyy' in a DataGrid.. On myGrid1 - Properties - Columns - myColumn1 - Text format string: I tried to put 'mm/dd/yyyy' in there and it displays...
2
by: jakub.bauer | last post by:
Hi, I have a table with in MS SQL database. A table consist a list of items bought by a customer with, item prices, item nubers etc. I would like to send an email with a list of items in the...
2
by: Mallik02 | last post by:
Hi I am new to MS-Access, I am getting the date in text format when I export it from other application. Could you please explain if there is any "Query" in Access to convert the text dates into...
0
by: yoavyoavyoav | last post by:
Hi There, I have some serious issue - I have a .Net application that is generating various reports in CSV format and then fires up excel from code to view this file. The file is viewed...
4
by: Jeff | last post by:
Hey I'm wondering how the Fixed-Width Text Format is What I know is that the top line in this text format will contain column names. and each row beneath the top line represent for example a...
6
by: and1 | last post by:
hello .. hmm currently i'm working on vba in excel, apparently i use ADO to extract a table data from access to excel and it works fine. the problem is when i use the extracted data to create a chart...
0
by: Bill Eberle | last post by:
In Access 2007 ADP connected to SQL Server Express, most forms allow Text Format attribute of Rich Text, but a few do not. In each case the SQL Server table field connected to the Access Text Box is...
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
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.