Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - Working with Dates in WMI
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Working with Dates in WMI
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-02-09

    Table of Contents:
  • Working with Dates in WMI
  • The Datetime format
  • Converting VBScript dates to WMI Dates
  • Converting WMI dates to VBScript Dates
  • Building Queries with Dates

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working with Dates in WMI - The Datetime format


    (Page 2 of 5 )

    Again, the Datetime format is just a string representation.  This statement includes a couple of points that you should keep in mind.  First, dates and times in WMI are always treated as strings; and second, this is a formatted string—meaning that the string has several parts.

    The string appears to be a fixed width floating point number.  It actually has a set number of digit groups, each relating to a part of the date and time.  It can be broken down into these parts very easily.

    20080213195848.000000-300

    Going back to the example date that we found in the beginning of this article, we can break this down into a legible date and time.  The string you see actually represents February 13, 2008 7:58 PM EST.  Here’s how.

    • The first four digits represent a four digit year: 2008.
    • The next two digits represent a two digit month: 02, or February.
    • The next two digits represent a two digit day: 13, the 13th of the month.
    • The next two digits represent a two digit hour in 24-hour format: 19, or 7 PM.
    • The next two digits represent a two digit minute: 58.
    • The final two digits before the decimal point represent a two digit second: 48.
    • The first six digits following the decimal point represent microseconds.  These are often not used, but must be represented by zeros to maintain the fixed length of the Datetime value.
    • The last portion of the datetime format is a signed three digit value that represents the time zone as a GMT offset: -300, or minus 300 minutes (GMT -5 Hours).  This represents Eastern Standard Time.

    So the fixed width Datetime format looks like this:  YYYYMMDDhhmmss.mmmmmm±UUU

    It’s important to understand the last (UUU) portion of this thoroughly.  By definition this is the offset in number of minutes that the time deviates from UTC.  This is why it is recommended that dates are first converted to GMT, since GMT has a UTC offset value of 0.

    More Windows Scripting Articles
    More By Nilpo


     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek