Convert date to Day_of_Week

(imported topic written by SystemAdmin)

I’m trying to convert a date into a Day_of_week

“11/7/2012” -> Wed

here’s the actual code

Q: ((parenthesized parts 1 of it, parenthesized parts 2 of it, parenthesized parts 5 of it) of matches (regex "^(.*)\t(.*)\t(.*)\t(.*)\t(.*)") of (it as string) of (lines whose (it contains "Run time") of file (value of variable "allusersprofile" of environment & "\Application Data\McAfee\DesktopProtection\OnDemandScanLog.txt"))as string)
 
A: 6/11/2011, 1:00:33 AM, Run time             : 0:00:29
A: 7/2/2011, 2:27:17 AM, Run time             : 2:27:04
A: 7/9/2011, 3:00:33 AM, Run time             : 0:00:32
A: 7/16/2011, 2:00:51 AM, Run time             : 1:00:41
A: 7/23/2011, 3:06:33 AM, Run time             : 2:06:17
A: 7/30/2011, 2:00:44 AM, Run time             : 1:00:35

I want to put a day in the list

A: MON, 6/11/2012, 1:00:33 AM, Run time             : 0:00:29
A: MON, 7/2/2012, 2:27:17 AM, Run time             : 2:27:04
A: TUE, 7/10/2012, 3:00:33 AM, Run time             : 0:00:32
A: MON, 7/16/2012, 2:00:51 AM, Run time             : 1:00:41
A: WED, 7/25/2012, 3:06:33 AM, Run time             : 2:06:17
A: SUN, 7/29/2012, 2:00:44 AM, Run time             : 1:00:35

(imported comment written by SystemAdmin)

The way I would approach it is to set it as a date object:

q: date “12 Nov 2012”

A: Mon, 12 Nov 2012

But first you would have to get the format mm/dd/yyyy into “day 3_digit_mo 4_digit_year”

There are probably more efficient ways but this works. You’ll just have to convert the "parenthesized part 1 of it:

((preceding text of first “/” of it & " " & preceding text of first “/” of following text of first “/” of it as integer as month as three letters & " " & following text of last “/” of it) of “12/12/2012”) as date

Good luck

(imported comment written by SystemAdmin)

Take it one step further if you want it in the same format with:

(day_of_week of (it as date) as three letters, it) of ((preceding text of first “/” of it & " " & preceding text of first “/” of following text of first “/” of it as integer as month as three letters & " " & following text of last “/” of it) of “12/12/2012”)

(imported comment written by SystemAdmin)

works great… exactly what i was looking for… :slight_smile:

another question now… many of the systems have a huge amount of data… how do I treat

( Sat, 11 Jun 2011 )

or

6/11/2011

as a date so I can filter lines less then 90 days old

Q: ( 

if exists file (value of variable 
"allusersprofile" of environment & 
"\Application Data\McAfee\DesktopProtection\OnDemandScanLog.txt") then (((((preceding text of first 
"/" of following text of first 
"/" of it & preceding text of first 
"/" of it as integer as month as three letters & 
" " & following text of last 
"/" of it) of it) as date) of parenthesized parts 1 of it, parenthesized parts 1 of it, parenthesized parts 2 of it, parenthesized parts 5 of it) of matches (regex 
"^(.*)\t(.*)\t(.*)\t(.*)\t(.*)") of (it as string) of (lines whose (it contains 
"Run time") of file (value of variable 
"allusersprofile" of environment & 
"\Application Data\McAfee\DesktopProtection\OnDemandScanLog.txt"))as string) 

else 
"<File Not Exists>")   A: ( Sat, 11 Jun 2011 ), 6/11/2011, 2:00:33 AM, Run time             : 0:00:29 A: ( Sat, 02 Jul 2011 ), 7/2/2011, 4:27:17 AM, Run time             : 2:27:04 A: ( Sat, 09 Jul 2011 ), 7/9/2011, 2:00:33 AM, Run time             : 0:00:32 A: ( Sat, 16 Jul 2011 ), 7/16/2011, 3:00:51 AM, Run time             : 1:00:41

(imported comment written by SystemAdmin)

Now you’re going to have to filter by date. YOu can do that by first:

subract current date from date in the file:

current date - “12 Jan 2012” as date

and then check to see if it is less than 90 days

current date - “12 Jan 2012” as date < 90*day

(imported comment written by SystemAdmin)

Perhaps you can attach all or part of a log file?

(imported comment written by SystemAdmin)

Try something like this:

q: (preceding text of first “Scan Summary” of it as trimmed string & " - Run Time" & following text of first “Run time” of it as trimmed string) of (lines whose (it contains “Run time” and (current date - ((preceding text of first “/” of following text of first “/” of it & " " & (preceding text of first “/” of it) as integer as month as three letters as string & " " & following text of last “/” of it) as date ) of preceding text of first " " of it) >90*day) of file (value of variable “allusersprofile” of environment & “\Application Data\McAfee\DesktopProtection\OnDemandScanLog.txt”))

A: 1/14/2010 2:22:02 PM - Run Time: 14:21:59

A: 1/21/2010 2:29:32 PM - Run Time: 14:29:30

T: 0.469 ms

I used this log as a template: