|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
This is driving me crazy!What is the best way to take to string dates and times...
ie., 10-Oct-2005 10:30:16 AM and 11-Oct-2005 2:17:54 PM and then determine the number of seconds between these two dates? I must be missing a simple function to do the conversion... but I sure can't seem to find it... Thanks for the help. B Debug.Print DateDiff("s", #10-Oct-2005 10:30:16 AM#, #11-Oct-2005 2:17:54
PM#) Show quoteHide quote "Brian" <bkstig***@usa.net> wrote in message news:uh0EKjq0FHA.2652@TK2MSFTNGP14.phx.gbl... > What is the best way to take to string dates and times... > > ie., 10-Oct-2005 10:30:16 AM and 11-Oct-2005 2:17:54 PM > > and then determine the number of seconds between these two dates? > > I must be missing a simple function to do the conversion... but I sure > can't seem to find it... > > Thanks for the help. > > B > > Use this to convert from a string to a date:
Dim d1 As Date d1 = CDate(s) Show quoteHide quote "Brian" <bkstig***@usa.net> wrote in message news:uh0EKjq0FHA.2652@TK2MSFTNGP14.phx.gbl... > What is the best way to take to string dates and times... > > ie., 10-Oct-2005 10:30:16 AM and 11-Oct-2005 2:17:54 PM > > and then determine the number of seconds between these two dates? > > I must be missing a simple function to do the conversion... but I sure > can't seem to find it... > > Thanks for the help. > > B > > aha...
That's what I was missing... DateDiff! got it now. thanks. Show quoteHide quote "Someone" <nob***@cox.net> wrote in message news:uCzSQqq0FHA.2076@TK2MSFTNGP14.phx.gbl... > Use this to convert from a string to a date: > > Dim d1 As Date > > d1 = CDate(s) > > > "Brian" <bkstig***@usa.net> wrote in message > news:uh0EKjq0FHA.2652@TK2MSFTNGP14.phx.gbl... > > What is the best way to take to string dates and times... > > > > ie., 10-Oct-2005 10:30:16 AM and 11-Oct-2005 2:17:54 PM > > > > and then determine the number of seconds between these two dates? > > > > I must be missing a simple function to do the conversion... but I sure > > can't seem to find it... > > > > Thanks for the help. > > > > B > > > > > > "Brian" <bkstig***@usa.net> wrote in message As Someone said (and I still implore him [her?] to come up with some kind of news:uh0EKjq0FHA.2652@TK2MSFTNGP14.phx.gbl... > What is the best way to take to string dates and times... > > ie., 10-Oct-2005 10:30:16 AM and 11-Oct-2005 2:17:54 PM > > and then determine the number of seconds between these two dates? > > I must be missing a simple function to do the conversion... but I sure > can't seem to find it... better alias), DateDiff is what you're looking for. However, anytime you're dealing with dates and times in string format, you can run into other problems. Therefore, I suggest that you always convert the date/time strings to a Date data type first. If there's a problem with the string, you'll find out about it right then and can take corrective action BEFORE you attempt anything else that may result in erroneous results. -- Mike Microsoft MVP Visual Basic |
|||||||||||||||||||||||