Solved

To emoreau

Posted on 2000-03-07
4
218 Views
Last Modified: 2010-05-02
emoreau,
Is it possible to break up the Minute,Hour,Day,Month & Year into
seperate textboxes.From your previous answer to my Date subtract question.
Thanks
Dave Steers
0
Comment
Question by:dsteers
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Vbmaster
ID: 2590948
Sure thing, you can use the.. hold on to ya hat now... the Year(Date), Month(Date), Day(Date), Hour(Date), Minute(Date) functions. For example...

  Me.Caption = Year(Now)       'shows the year number
  Me.Caption = Month(Now)    'shows the month number
  Me.Caption = Day(Now)        'shows the day number
  Me.Caption = Hour(Now)      'shows the hour number
  Me.Caption = Minute(Now)   'shows the minute number
  Me.Caption = Second(Now)  'guess what?
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 20 total points
ID: 2591607
Thanks for the points!
0
 

Author Comment

by:dsteers
ID: 2603578
Guys,
Using the following code how do I seperate the Day,Month & Year into
seperate textboxes so that they can be entered by the user.
I.e 2 Day textboxes,2 Month textboxes & 2 Year textboxes.
Thanks

Code (thanks to emoreau)

Option Explicit

Private Sub Command1_Click()
Dim dtm1 As Date
Dim dtm2 As Date
Dim lngDiff As Long
Dim lngDays As Long
Dim lngHours As Long
Dim lngMinutes As Long

    dtm1 = "2000/03/08 13:40"
    dtm2 = "2000/03/09 2:00"
     
    'Returns number of minutes
    lngDiff = DateDiff("n", dtm1, dtm2)
     
    'Extract days
    If lngDiff > (24 * 60) Then
        lngDays = Int(lngDiff / (24 * 60))
        lngDiff = lngDiff - (lngDays * 24 * 60)
    End If
     
    'Extract Hours
    If lngDiff > 60 Then
        lngHours = Int(lngDiff / 60)
        lngDiff = lngDiff - (lngHours * 60)
    End If
     
    'Extract Minutes
    lngMinutes = lngDiff
     
    MsgBox "Difference between dates: " & _
           lngDays & " days, " & _
           lngHours & " hours and " & _
           lngMinutes & " minutes."
End Sub

Thanks
Dave Steers
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2604469
You can use the CDate to build your date:

    dtm1 = CDate(txtYear1 & "/" & txtMonth1 & "/" & txtDay1 & " " & txtHour1 & ":" & txtMinute1)
    dtm2 = CDate(txtYear2 & "/" & txtMonth2 & "/" & txtDay2 & " " & txtHour2 & ":" & txtMinute2)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library 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…

746 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