Date Woes

  • Thread starter Thread starter Kevin Vaughn
  • Start date Start date
K

Kevin Vaughn

I am trying to convert a date from this format:

yyyymmddHHMMSS.mmmmmmsUUU

to a format that ASP.NET (VB.NET) understands.

The above date format is used by the WMI datetime type. I don't care about
the mmmmmmsUUU part, as that counts milliseconds and microseconds. The sUUU
is a three digit offset indicating the number of minutes that the
originating time zone deviates from UTC. Other than that, the format is
pretty self explanatory.

(more info here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/
date_and_time_format.asp)

I can imagine all kinds of weird, contorted, or otherwise convoluted ways of
formatting this date, but I wanted to check and see if there's an better way
before I go off and spend gobs of time reinventing the wheel.

Any ideas?

-Kevin
 
the easiest way i've seen would probably be:

Dim myDate as Date

myDate = yearstring & "/" & monthstring & "/" & daystring & " " & hourstring
& ":" & minstring

which means you'll have to split up the string somewhere into those
strings...

good luck
 
Regular Expressions are GREAT for this kind of parsing...
Concise, easy to change and understand...
 
Back
Top