Support
ChronoScan - Document Capture Software - Chronoscan VB Scriting - ChronoScan Forum
× Welcome to the ChronoScan forum!

Tell us and our members who you are, what you like and why you became a member of this site.
We welcome all new members and hope to see you around a lot!

Chronoscan VB Scriting

More
24 Feb 2020 05:51 #3225 by amar7295
Hello Everyone,

I have compared the captured field date with the current system date using the VB Script. It works partial because when i am trying to compare the captured field date 01/04/2020 with a current system date(24/02/2020) which is greater than current system date, the script is unable to give the proper comparison. it shows the current system date is greater than the field value which is actually less than the filed captured value(01/04/2020). i tried different date conversion methods but it shows the same error. So can anyone give me the solution over this problem

kind regards.

Please Log in or Create an account to join the conversation.

More
24 Feb 2020 17:58 #3226 by Gsimao
Replied by Gsimao on topic Chronoscan VB Scriting
amar7295,
can you post the script you are using?
The following user(s) said Thank You: amar7295

Please Log in or Create an account to join the conversation.

More
25 Feb 2020 05:50 #3227 by amar7295
Replied by amar7295 on topic Chronoscan VB Scriting
Thank you Gsimao for reply. I have posted the script that i am using right now. Another thing is, I kept the field type as date in field properties, so it takes the date in mm dd yyyy format. Here is the code:

dim d, m, y
dim d1, d2, y2

dim sd, fv
dim cv1, cv2
''*************************** Taking System Date ********************
sd = Date()

''*************************** Converting into dd/mmm/yyyy Format *************
d = day(sd)
if d<10 then
d = "0" & d
End if

m = MonthName(month(sd), true)
y = year(sd)

cv1 = d& "/" & m&"/" &y
''**************** Printing the converted Date*************
msgbox(cv1)

''*********************************** Getting the User field Date *************************
fv = UserField_Expiry_Date.value

''*************************** Converting into dd/mmm/yyyy Format *************

d1 = day(fv)
if d1<10 then
d1 = "0" & d1
End if

m1 = MonthName(month(fv), true)
y1 = year(fv)

cv2 = d1& "/" &m1 &"/" &y1
''**************** Printing the converted Date*************

msgbox(cv2)


''********************* Comparing both the dates ***********************

if cv1>cv2 then
UserField_Expiry_Date.ValidateStatus = 0
UserField_Expiry_Date.ValidateMessage = "Document is expired"
Else
UserField_Expiry_Date.ValidateStatus = 1
UserField_Expiry_Date.ValidateMessage = "Document is valid"
End if
''********************* End of Loop ******************************************

Please Log in or Create an account to join the conversation.

More
25 Feb 2020 05:50 #3228 by amar7295
Replied by amar7295 on topic Chronoscan VB Scriting
Thank you Gsimao for reply. I have posted the script that i am using right now. Another thing is, I kept the field type as date in field properties, so it takes the date in mm dd yyyy format. Here is the code:

dim d, m, y
dim d1, d2, y2

dim sd, fv
dim cv1, cv2
''*************************** Taking System Date ********************
sd = Date()

''*************************** Converting into dd/mmm/yyyy Format *************
d = day(sd)
if d<10 then
d = "0" & d
End if

m = MonthName(month(sd), true)
y = year(sd)

cv1 = d& "/" & m&"/" &y
''**************** Printing the converted Date*************
msgbox(cv1)

''*********************************** Getting the User field Date *************************
fv = UserField_Expiry_Date.value

''*************************** Converting into dd/mmm/yyyy Format *************

d1 = day(fv)
if d1<10 then
d1 = "0" & d1
End if

m1 = MonthName(month(fv), true)
y1 = year(fv)

cv2 = d1& "/" &m1 &"/" &y1
''**************** Printing the converted Date*************

msgbox(cv2)


''********************* Comparing both the dates ***********************

if cv1>cv2 then
UserField_Expiry_Date.ValidateStatus = 0
UserField_Expiry_Date.ValidateMessage = "Document is expired"
Else
UserField_Expiry_Date.ValidateStatus = 1
UserField_Expiry_Date.ValidateMessage = "Document is valid"
End if
''********************* End of Loop ******************************************

Please Log in or Create an account to join the conversation.

More
25 Feb 2020 12:10 #3229 by Gsimao
Replied by Gsimao on topic Chronoscan VB Scriting
"if cv1>cv2 then" is a string comparison. If you are working with dates you should not use that. Try DateDiff("d",cv1,cv2) instead. This will give you the number of days of difference between one date and the other. If it is negative than cv1 is bigger.
The following user(s) said Thank You: amar7295

Please Log in or Create an account to join the conversation.

More
06 Mar 2020 05:18 #3230 by amar7295
Replied by amar7295 on topic Chronoscan VB Scriting
Thank you Gsimao.

Please Log in or Create an account to join the conversation.

Time to create page: 0.266 seconds