-
Feb 12th, 2015, 07:55 AM
#41
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
-
Feb 12th, 2015, 08:14 AM
#42
Re: [RESOLVED] trying to update a Date field based on ID dosnt work proper
Originally Posted by salsa31
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
-
Feb 12th, 2015, 08:15 AM
#43
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~
-
Feb 12th, 2015, 09:15 AM
#44
Thread Starter
Enjoy the moment
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|