date time manipulation

Posted on 1999-07-19
Medium Priority
Last Modified: 2012-05-04
I have a (start date & start time) and a (finish date & finish time) ,I need to calculate the number of hours between each.
Cheers Turlough
Question by:turloughm
  • 2
LVL 18

Accepted Solution

deighton earned 200 total points
ID: 1525754
Dim x As Date, y As Date, hours

x = Now
y = Now + 10

hours = DateDiff("h", x, y)

MsgBox hours
LVL 18

Expert Comment

ID: 1525755
  Dim Tstart As Date
    Dim Tend  As Date
    Dim sdate1 As String
    Dim stime1 As String
    Dim sdate2 As String
    Dim stime2 As String
    sdate1 = "23/04/66"
    stime1 = "10:10:05"
Here is a more thorough example.  Check your date format settings, locale etc.

    sdate2 = "24/04/66"
    stime2 = "11:25:02"

    Tstart = CDate(sdate1 & " " & stime1)
    Tend = CDate(sdate2 & " " & stime2)
    MsgBox DateDiff("h", Tstart, Tend)


Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

619 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