Results 1 to 5 of 5

Thread: I need Help

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Location
    Canada
    Posts
    11

    I need Help

    Hi guys
    i'm new to the place here
    & i need some help ...
    i want to make a program that calculate the deffernece between to dates & times so it would give me the result as:
    ..Days .. Hours..Mins. ..Sec.
    what do i have to do or at least is there any related sites to this matter
    thanks.
    rami

  2. #2
    jim mcnamara
    Guest
    Code:
    Dim tmp as date
    tmp = DateDiff(newdate,olddate)
    tmp = format("dd hh:mm:ss",tmp)
    where newdate and olddate are times or date/times. Look up Format function in help and you may see a format option that suits your specifications better - like long date - time format.

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Location
    Canada
    Posts
    11
    thank you Jim for replying
    acctually what i want is suppose i want to calculate how many days,hours,mins,secs. for xmas to come so
    i use this code:
    Private Sub Timer1_Timer()
    Dim TheDate As Date ' Declare variables.
    TheDate = "25/12/2001 12:00:00 AM"
    Label1.Caption = DateDiff("d", Now, TheDate) & "days" & DateDiff("h", Now, TheDate) & "Hours" & DateDiff("n", Now, TheDate) & "Minutes" & DateDiff("s", Now, TheDate) & "Seconds"
    Label2.Caption = Format(Time, "long time")
    End Sub
    but still it's not giving me the exact hours & mins .. do i have to change something or not sure yet
    thank u again

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'your program is doing what you ask of it. "" GIGO"
    'You asked for the time difference in days, the difference in hours,
    'the difference in minuites & the difference in seconds
    '
    'you merely forgot to express it as HH/MM/SS left in the day and not the total time
    'from now to Christmas.
    '
    Option Explicit
    
    Private Sub Form_Load()
      Timer1.Enabled = True
      Timer1.Interval = 100
    End Sub
    
    
    Private Sub Timer1_Timer()
       Dim rightnow, daysleft, hoursleft, minutesleft, theDate, secondsleft
       theDate = "25/12/2001 12:00:00 AM"
       rightnow = Now  ' Now returns the current date/time.
       daysleft = DateDiff("d", Now, theDate)
       'functions for current hour/minuite/second
       hoursleft = 24 - Hour(rightnow)
       minutesleft = 60 - Minute(rightnow)
       secondsleft = 60 - Second(rightnow)
       Label1.Caption = daysleft & " days " & hoursleft & " hours " & _
         minutesleft & " minutes " & _
         secondsleft & " seconds "
       Label2.Caption = Format(Time, "long time")
    
    If Now = theDate Then
       Timer1.Enabled = False
       Exit Sub
    End If
    
    End Sub
    Last edited by HeSaidJoe; Nov 26th, 2001 at 01:12 PM.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Location
    Canada
    Posts
    11
    thank you very much buddy
    for replying & helping me with this
    i'm so greatfull to u

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width