Solved

time comparison...

Posted on 1999-01-16
3
124 Views
Last Modified: 2010-05-18
I would like to compare system time with time that has been stored in MS Access database field (of type day/time). my problem is that the time from the database is always in 12 hour clock whereas system time is always in 24 hour clock
0
Comment
Question by:serameng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Expert Comment

by:ikxsoft
ID: 1468957
since the minutes are the same in 12 and 24 hour time, all you would have to do is add 12 hours to each hour past and including 12 noon, but before 12 night.
0
 

Author Comment

by:serameng
ID: 1468958
Isn't there another way? You see I get the time from the database and do not necessarily know its value. So I wouldn't know if its 12 noon, 12 night, or whatever. And please give me an example of your solution.
0
 
LVL 10

Accepted Solution

by:
caraf_g earned 10 total points
ID: 1468959
If your time in your database field is stored as a Date/Time field, it isn't actually stored in a particular format. In VB you can simply retrieve it in a variable of type Date

Then, to calculate the difference between dates

Dim datDate1 As Date
Dim datDate2 As Date
Dim dblDiff As Double

dblDiff = datDate2 - datDate1

Now - the integer portion of dblDiff is the difference between datDate2 and datDate1 in days, but the fraction is the difference in fractions of a day.

So to calculate the difference in minutes
dblDiff = dblDiff * 24 'There are 24 hours in the day
dblDiff = dblDiff * 60 'There are 60 minutes in an hour


0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best way to parse out a json string in VB6? 10 279
Excel - Save a copy of work book 13 91
Set email body to html using vbscript 6 71
checkbox to hide entire section 10 58
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question