Solved

time comparison...

Posted on 1999-01-16
3
123 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
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying 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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 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