Change string to date

(imported topic written by SystemAdmin)

I have a value Im returning from an XML file, the value is a date and time, the actual value is

20100416184511

so (4 year/2 month/2 day/2 hour/2 minute/2 second)

I split it up so its readable with this

Q: (first 4 of it & “-” & last 2 of the first 6 of it & “-” & last 2 of the first 8 of it & " " & first 2 of the last 6 of it & “:” & first 2 of the last 4 of it) of (substring between “%22” of (attribute 2 of select “ns:SiteLists” of xml document of file (name of drive of windows folder & “\Documents and Settings\All Users\Application Data\McAfee\Common Framework\ServerSiteList.xml”) as xml))

A: 2010-04-16 18:45:11

and what im trying to do is determine how many days old that number is,

Q: now - 20100416

A: 10 days old

This value is actually the last time McAfee communicated to it’s EPO server

(imported comment written by jeremylam)

You’ll have to reformat the time to match the " as time" inspector in order to get a time object:

q: “Mon, 26 Apr 2010 12:51:55 -0700” as time

A: Mon, 26 Apr 2010 12:51:55 -0700

T: 0.082 ms

I: singular time

(imported comment written by NoahSalzman)

I took Jesse’s suggestion in

this thread

to come up with this:

Q: current date - date (( last 2 of it & " " & first 3 of (month (last 2 of first 6 of it as integer) as string) & " " & first 4 of it) of (first 8 of “20100416184511”))

A: 10 days

(imported comment written by SystemAdmin)

Thank You… :slight_smile:

Works Great!

Theres the whole thing

Q: current date - date (( last 2 of it & " " & first 3 of (month (last 2 of first 6 of it as integer) as string) & " " & first 4 of it) of (first 8 of ((first 4 of it & last 2 of the first 6 of it & last 2 of the first 8 of it) ) of (substring between “%22” of (attribute 2 of select “ns:SiteLists” of xml document of file (name of drive of windows folder & “\Documents and Settings\All Users\Application Data\McAfee\Common Framework\ServerSiteList.xml”) as xml))))

A: 12 days

Error checking…

if exists file (name of drive of windows folder & “\Documents and Settings\All Users\Application Data\McAfee\Common Framework\ServerSiteList.xml”) then (current date - date (( last 2 of it & " " & first 3 of (month (last 2 of first 6 of it as integer) as string) & " " & first 4 of it) of (first 8 of ((first 4 of it & last 2 of the first 6 of it & last 2 of the first 8 of it) ) of (substring between “%22” of (attribute 2 of select “ns:SiteLists” of xml document of file (name of drive of windows folder & “\Documents and Settings\All Users\Application Data\McAfee\Common Framework\ServerSiteList.xml”) as xml))))) as string else “”

(imported comment written by jessewk)

Just curious… what kind of results are you seeing in your environment for that query?

(imported comment written by SystemAdmin)

Sorry I thought it auto subscribed when ever I poster ?

Do you mean McAfee EPO stats in general

Days since Last Communication (LastUpdateCheck) Period Every Report

if exists file (name of drive of windows folder & 
"\Documents and Settings\All Users\Application Data\McAfee\Common Framework\ServerSiteList.xml") then (

if (current date - date ((last 2 of it & 
" " & first 3 of (month (last 2 of first 6 of it as integer) as string) & 
" " & first 4 of it) of (first 8 of ((first 4 of it & last 2 of the first 6 of it & last 2 of the first 8 of it)) of ((

if (exists key 
"HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\Framework" of registry) then (value 
"LastUpdateCheck" of key 
"HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\Framework" of 

native registry as string) 

else 
"00000000000000"))))) as string = 
"00:00:00" then 
"0 days" 

else (current date - date ((last 2 of it & 
" " & first 3 of (month (last 2 of first 6 of it as integer) as string) & 
" " & first 4 of it) of (first 8 of ((first 4 of it & last 2 of the first 6 of it & last 2 of the first 8 of it)) of ((

if (exists key 
"HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\Framework" of registry) then (value 
"LastUpdateCheck" of key 
"HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\Shared Components\Framework" of 

native registry as string) 

else 
"00000000000000"))))) as string) as string 

else 
"<file not exists>"

Days since Last Communication (LastUpdateCheck)Result Count Percentage

420 15.23%

0 days 2154 78.10%

1 day 6 0.22%

2 days 1 0.04%

3 days 1 0.04%

5 days 1 0.04%

9 days 1 0.04%

12 days 1 0.04%

16 days 2 0.07%

20 days 1 0.04%

21 days 2 0.07%

23 days 1 0.04%

28 days 1 0.04%

29 days 1 0.04%

30 days 1 0.04%

35 days 1 0.04%

37 days 1 0.04%

41 days 1 0.04%

42 days 1 0.04%

47 days 1 0.04%

49 days 1 0.04%

54 days 2 0.07%

56 days 1 0.04%

58 days 1 0.04%