Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatdatetime

Status
Not open for further replies.
Oct 10, 2003
90
US
Not sure how to accomplish what I want. Essentially, I want to create a list of computers that have not been rebooted in the last x days from today.

If I use the date function, I get 7/26/2004

Using

Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)

Wscript.echo "Date of Last Boot: " & (Left(objItem.LastBootUpTime,8))

I get 20040726

I cant seem to use the formatdatetime function to rework either date into the same format as the other. Unless I can get both in the same format, then I can't use the datediff function either.

Suggestions?
 
You can play with the Year, Month and Day functions.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Starting to play with them now, but should I be able to format the objItem.LastBootUpTime? Or is it a value that just can't be altered because the way it is returned?
 
To retrieve the LastBootUpTime as a date you may try something like this:
lbut = DateSerial(Left(objItem.LastBootUpTime,4), Mid(objItem.LastBootUpTime,5,2), Mid(objItem.LastBootUpTime,7,2))
And then you can use the DateDiff function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top