Compare date string

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
JoeBo747
Newbie
Posts: 10
Joined: Thu Sep 08, 2005 8:42 am

Compare date string

Post by JoeBo747 » Thu Nov 10, 2005 4:47 pm

I want to compare the date of an update file on the server to todays date and then send an e-mail if the Date and my the update file do not match. I have tried the following but the test returns the second message box no matter what the date are.

FileDate>\\server\sys\Anti_Virus_Updates\Current\VSCANDAT1000\DAT\0000\update.ini,MyFileDate

Month>month
Day>day
Year>year
if %myfiledate%Mcafee update out
endif
if %myfiledate%=%year%%month%%day%
message> %year%%month%%day% %myfiledate%, Mcafee update Current
endif
:cry:
JOE

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Nov 10, 2005 4:50 pm

Should be:

if>%myfiledate%Mcafee update out
endif

And:

if>%myfiledate%=%year%%month%%day%
message> %year%%month%%day% %myfiledate%, Mcafee update Current
endif
MJT Net Support
[email protected]

JoeBo747
Newbie
Posts: 10
Joined: Thu Sep 08, 2005 8:42 am

Post by JoeBo747 » Thu Nov 10, 2005 5:08 pm

Thanks :lol:
JOE

JoeBo747
Newbie
Posts: 10
Joined: Thu Sep 08, 2005 8:42 am

Post by JoeBo747 » Thu Nov 10, 2005 5:23 pm

I think I have jumped the gun, The script still returns the first message no matter what the two dates.

FileDate>\\server\sys\WINDATA\Anti_Virus_Updates\Current\VSCANDAT1000\DAT\0000\update.ini,MyFileDate

Month>month
Day>day
Year>year
if>%myfiledate%%year%%month%%day% %myfiledate%,
endif

And:

if>%myfiledate%=%year%%month%%day%
message> %year%%month%%day% %myfiledate%, Mcafee update Current
endif
JOE

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Nov 10, 2005 5:55 pm

Try this code:

FileDate>\\server\sys\WINDATA\Anti_Virus_Updates\Current\VSCANDAT1000\DAT\0000\update.ini,MyFileDate

Month>month
Day>day
Length>day,ld
If>ldday=0%day%
Endif
Year>year
Let>today=%year%%month%%day%
MessageModal>%MyFileDate% MyFileDateYes
Else
MessageModal>No
Endif

Let me know what appears in the first message box. Does it look right? If MyFileDate is less that today Yes will appear in the next message box, otherwise it will display No.

Your script was using non modal message boxes so it was probably just running right through and the second message was obliterating the first. Message (without the Modal) doesn't wait for you to press OK and the script carries on. MessageModal is what you want for debugging and showing the outcome of logical steps as you have time to read it and only when you hit OK will the script continue.
MJT Net Support
[email protected]

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Thu Nov 10, 2005 6:01 pm

Why does it work OK for me, even with just a "message" ?

//FileDate>c:\ados\pvt.txt,MyFileDate
FileDate>c:\ados\pv.txt,MyFileDate
Month>month
Day>day
Year>year
if>%myfiledate%%year%%month%%day% %myfiledate%,
endif
if>%myfiledate%=%year%%month%%day%
message>%year%%month%%day% %myfiledate% OK
endif

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Nov 10, 2005 6:04 pm

Well maybe the date of your file only matches one of the conditions.
MJT Net Support
[email protected]

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Thu Nov 10, 2005 6:42 pm

//FileDate>c:\ados\pvt.txt,MyFileDate
FileDate>c:\ados\pv.txt,MyFileDate

pvt.txt has today's date, and pv.txt is from 2002, so I tested both conditions.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Nov 10, 2005 6:54 pm

Well it's working correctly for you. JoeBo's problem must have been something else then. Was just covering all bases and simply pointing out that message (rather than MessageModal) does not wait and therefore using more than one message for debugging can be unhelpful as subsequent messages obliterate the first.
MJT Net Support
[email protected]

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Fri Nov 11, 2005 12:58 am

Ah :idea: sorry :oops: now I understand what you are saying. If it works it works, but if both conditions are coming up true then JoBoe would never know it because of using message rather than messagemodal.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts