Page 2 of 2 FirstFirst 12
Results 41 to 44 of 44

Thread: [RESOLVED] trying to update a Date field based on ID dosnt work proper

  1. #41
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,871

    Re: [RESOLVED] trying to update a Date field based on ID dosnt work proper

    A DateTime variable is actually a Double (a floating point number)
    The integer part (before the decimal point) is the date value.
    The fractional part is the amount of seconds divided by 86400 (the number of seconds in a day)

    Try this sample in a new project:
    Code:
    Option Explicit
    
    Private Sub Form_Load()
      Dim dNow As Double, dTime As Double
      Dim lDate As Long
      Dim lHH As Long, lMM As Long, dSS As Double
      Dim dSeconds As Double
      
      dNow = Now            ' the actual date/time
      lDate = Int(dNow)     ' remove the fraction (the time)
      dTime = dNow - lDate  ' remove the date to keep the time
      
      ' the time is stored as "seconds/86400" (86400 the number of seconds in a day)
      dSeconds = dTime * 86400
      ' get the hour, by dividing by the number of seconds in an hour
      lHH = Int(dSeconds / 3600)
      ' get the minutes
      lMM = Int((dSeconds - (3600 * lHH)) / 60)
      ' get the seconds
      dSS = dSeconds - (3600 * lHH) - (60 * lMM)
      
      Debug.Print "Actual date/time", Format(Now, "dd/mm/yyyy hh:mm:ss")
      Debug.Print "Numeric representation", dNow
      Debug.Print "Numeric date", lDate
      Debug.Print "Numeric time", dTime
      Debug.Print "Hours", lHH
      Debug.Print "Minutes", lMM
      Debug.Print "Seconds", dSS
      
    End Sub

  2. #42
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: [RESOLVED] trying to update a Date field based on ID dosnt work proper

    Quote Originally Posted by salsa31 View Post
    what is this code?
    wht it means?
    Code:
    Int(ZDateStart)+0.9993
    Arnout gave you already an explanation about the Date-Type (which is internally a Double)

    You can experiment with that for example in your Direct- (or Immediate-)Window.

    e.g. put the following (questionmark-preceded) expressions into your immediate-Window and press Enter:

    ?Int(Now) + 0.25 ... -> prints out (here on a german locale): 12.02.2015 06:00:00

    ?Int(Now) + 0.75 ... -> prints out (here on a german locale): 12.02.2015 18:00:00

    ?Int(Now) + 0.99999 ... -> prints out (here on a german locale): 12.02.2015 23:59:59

    ?Int(Now) + 0.9993 ... -> prints out (here on a german locale): 12.02.2015 23:59:00

    Olaf

  3. #43
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    Re: [RESOLVED] trying to update a Date field based on ID dosnt work proper

    Hey Salsa! If DataMiser, Olaf and some others paid your plane ticket, would you be willing to attend a 30-day class on VB6 and SQL from dilettante?

    ~smile~

  4. #44

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: [RESOLVED] trying to update a Date field based on ID dosnt work proper

    Hey Salsa! If DataMiser, Olaf and some others paid your plane ticket, would you be willing to attend a 30-day class on VB6 and SQL from dilettante?
    lool

Page 2 of 2 FirstFirst 12

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