thaicosmic.com

หนัง

วันเสาร์ที่ 27 กุมภาพันธ์ พ.ศ. 2559

ตรวจสอบความถูกต้องเลขประจำตัวประชาชน - เลขประชาชน

(mysql query)

Right(11-((Left(person.idcard,1)*13)+(Mid(person.idcard,2,1)*12)+(Mid(person.idcard,3,1)*11)
+(Mid(person.idcard,4,1)*10)+(Mid(person.idcard,5,1)*9)+(Mid(person.idcard,6,1)*8)+(Mid(person.idcard,7,1)*7)
+(Mid(person.idcard,8,1)*6)+(Mid(person.idcard,9,1)*5)+(Mid(person.idcard,10,1)*4)+(Mid(person.idcard,11,1)*3)
+(Mid(person.idcard,12,1)*2)) Mod 11,1) = Right(person.idcard,1)

Excel

=IF(RIGHT(11-MOD((LEFT(A1,1)*13)+(MID(A1,2,1)*12)+(MID(A1,3,1)*11)+(MID(A1,4,1)*10)+(MID(A1,5,1)*9)+(MID(A1,6,1)*8)+(MID(A1,7,1)*7)+(MID(A1,8,1)*6)+(MID(A1,9,1)*5)+(MID(A1,10,1)*4)+(MID(A1,11,1)*3)+(MID(A1,12,1)*2),11),1)= RIGHT(A1,1),TRUE,FALSE)