Recently Thomas answered my question about how to obtain a timestamp with the following:
dim d As new date
system.Log System.LogLevelError, “Timestamp :” + d.ShortDate +" " + d.ShortTime
Probably I phrased by question the wrong way. What I want is a way of inserting the current time (hrs, mins, secs) in a message sent to my own message file. As this:
Dim msg as String
msg = “This is my message” + timestamp
If it is a log file of sorts, I’d use Eli’s method as you will have a consistent time easy to read/parse, i.e. 05:15:22. If for human consumption, you can of course use Eli’s method but with d.ShortTime instead of the individual Format calls.
[quote=105019:@Russ Lunn]i would advise logging using yyyymmddhhmmss because…
it will still work if you go over midnight boundaries
if you log to an external file the fact that the dates are in sequence will allow you to lift it into excel and sort/filter very Easilly.[/quote]
If for a log, indeed include the full date/time. Also, the d.SQLDateAndTime format might actually be better for a log? It is a bit more readable as humans will be looking at the log from time to time I’d guess, Excel should still be able to parse the date fine and the dates are still sequential (text in a file or via Excel’s sort).
For example:
20140627085711 - my message
2014-06-27 08:57:11 - my message
or in teh heat of the moment when stuff is broken, it is harder to read. Someone that has to do “Ops” along with dev and engineering, make your “Ops” moments as easy for you as possible.
Personally I just use “d.SQLDateTime” and my timestamp. it might not be perfect but it is easy to read and and understand.