This topic is locked

Date Compare in Version 6.3

5/31/2015 10:18:35 AM
ASPRunnerPro General questions
F
Flavio author

Hello, i am putting this code in the "BeforeEdit" event, taken somewhere in this forum, to avoid users to edit their own if "Shift_Date" is earlier than 7 days.
It used to work in previous versions of Asprunnerpro but now its no longer working with version 6.3

Where am i wrong?

Thank you in advance,
Flavio

Dim dict

Set dict = values

if (weekday(date())) = 1 then
intdata = dict("Shift_Date")
if DateDiff("d",now(), intdata) < 7 then
Beforeedit=false
Response.Write "<script>alert('ERROR!!')</script>"
dim tmpDict, msg, rsOld, i

set tmpDict = CreateObject("Scripting.Dictionary")

tmpDict("to")="dispo@google.it"

tmpDict("subject")="Utente " & session("userid") & " Tentativo Modifica Illegale"

tmpDict("body")="Quel KRAPA con utenza '" & session("userid") & "' ha eseguito un tentativo (non riuscito) di modifica disponibilità fuori tempo massimo."

set ret=runner_mail(tmpDict)

if not ret("mailed") then

response.write ret("message")

end if
else


set tmpDict = CreateObject("Scripting.Dictionary")

tmpDict("to")="dispo@google.it"

tmpDict("subject")="Dispo di " & oldvalues("descrizione") & " Modificata: VECCHI"

msg=""
' modify the following SQL query to select fields you like to send

set rsOld = dal.Table(strTableName).Query(where,"")

if not rsOld.eof then

for i=0 to rsOld.Fields.Count-1

if not IsBinaryType(rsOld.Fields(i).Type) then _

msg = msg & rsOld.Fields(i).Name & " : " & rsOld(rsOld.Fields(i).Name) & vbcrlf

next

end if

rsOld.Close:set rsOld = Nothing
tmpDict("body")=msg

set ret=runner_mail(tmpDict)

if not ret("mailed") then

response.write ret("message")

end if

beforeedit=true

end if

end if
admin 5/31/2015

It should work the same way in all versions since DateDiff is a standard VBscript function and this comparison is not ASPRunnerPro specific. Cannot provide a better insight without having access tot he application and data.