Solved

time comparison...

Posted on 1999-01-16
3
121 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

930 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now