跳到主要内容

根据身份证号自动计算生肖

生肖的计算逻辑是根据出生年份(7~10位)对 12 求余数判断生肖;生份证号的 7~12 位为该身份证对应成员的出生年份。

1. IF 函数计算

通过 IF 函数将各种情况都罗列出来,符合情况的则自动计算出生肖

下述代码可直接复制到公式编辑器内,注意替换身份证号字段

{"text":"IF(EQ(LEN(​身份证号​),18),IF(EQ(MOD(VALUE(MID(​身份证号​,7,4)),12),0),\"猴\",IF(EQ(MOD(VALUE(MID(​身份证号​,7,4)),12),1),\"鸡\",IF(EQ(MOD(VALUE(MID(​身份证号​,7,4)),12),2),\"狗\",IF(EQ(MOD(VALUE(MID(​身份证号​,7,4)),12),3),\"猪\",IF(EQ(MOD(VALUE(MID(​身份证号​,7,4)),12),4),\"鼠\",IF(EQ(MOD(VALUE(MID(​身份证号​,7,4)),12),5),\"牛\",IF(EQ(MOD(VALUE(MID(​身份证号​,7,4)),12),6),\"虎\",IF(EQ(MOD(VALUE(MID(​身份证号​,7,4)),12),7),\"兔\",IF(EQ(MOD(VALUE(MID(​身份证号​,7,4)),12),8),\"龙\",IF(EQ(MOD(VALUE(MID(​身份证号​,7,4)),12),9),\"蛇\",IF(EQ(MOD(VALUE(MID(​身份证号​,7,4)),12),10),\"马\",\"羊\"))))))))))),\"\")","marks":[{"from":{"line":0,"ch":10,"sticky":null},"to":{"line":0,"ch":16,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":42,"sticky":null},"to":{"line":0,"ch":48,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":86,"sticky":null},"to":{"line":0,"ch":92,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":130,"sticky":null},"to":{"line":0,"ch":136,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":174,"sticky":null},"to":{"line":0,"ch":180,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":218,"sticky":null},"to":{"line":0,"ch":224,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":262,"sticky":null},"to":{"line":0,"ch":268,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":306,"sticky":null},"to":{"line":0,"ch":312,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":350,"sticky":null},"to":{"line":0,"ch":356,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":394,"sticky":null},"to":{"line":0,"ch":400,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":438,"sticky":null},"to":{"line":0,"ch":444,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":482,"sticky":null},"to":{"line":0,"ch":488,"sticky":null},"value":"textField_ksfyitkm","invalid":false}],"isCmData":true}
  • IF(判断条件,结果为 true 的返回值, 结果为 false 的返回值)
  • EQ(value1,value2)两个值相等返回 true,支持数字,日期
  • LEN(text):返回文本字符串中的字符个数
  • VALUE():把 MID 函数取出的字符串转换成数字
  • MOD(number, divisor):返回两数相除的余数
  • MID(A,B,C):在 A 字符串中,从第 B 位开始取出 C 个字符

计算生肖

2. 视频演示

计算生肖视频讲解

3. 更多身份资料提取欢迎阅读文档👇:

1.根据身份证号自动计算生日

2.根据身份证号自动计算性别

3.根据身份证号自动计算星座

4.根据身份证号自动计算省份

宜搭为了更好的优化宜搭使用手册内容和质量,占用您3-5分钟时间,辛苦填写一下文档反馈问卷。文档反馈问卷是匿名提交,同时问卷信息仅用于宜搭文档体验反馈收集,感谢您对宜搭的支持!

点此填写调研问卷


--------------------获取宜搭最新信息,欢迎关注我们--------------------

Copyright © 2024钉钉(中国)信息技术有限公司和/或其关联公司浙ICP备18037475号-4