Solved

time comparison...

Posted on 1999-01-16
3
120 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

772 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

13 Experts available now in Live!

Get 1:1 Help Now