根据身份证号自动计算星座
星座是根据出生月日(11~14位)进行匹配;例如,当出生月日在三月 21 和四月 19 日之间就为白羊座,其他星座按此继续编写。
1. IF 函数判定
采用 IF 函数将进行公式编写。
IF(A,B,IF(C,D,E))理解为如果满足 A,则返回 B;如果不满足 A 但是满足 C,则返回 D;如果 A 与 C 均不满足否则返回 E
下述代码可直接复制到公式编辑器内,注意替换身份证号字段。
{"text":"IF(EQ(LEN(身份证号),18),IF(AND(GE(VALUE(MID(身份证号,11,4)),321),LE(VALUE(MID(身份证号,11,4)),419)),\"白羊座\",IF(AND(GE(VALUE(MID(身份证号,11,4)),420),LE(VALUE(MID(身份证号,11,4)),520)),\"金牛座\",IF(AND(GE(VALUE(MID(身份证号,11,4)),521),LE(VALUE(MID(身份证号,11,4)),621)),\"双子座\",IF(AND(GE(VALUE(MID(身份证号,11,4)),622),LE(VALUE(MID(身份证号,11,4)),722)),\"巨蟹座\",IF(AND(GE(VALUE(MID(身份证号,11,4)),723),LE(VALUE(MID(身份证号,11,4)),822)),\"狮子座\",IF(AND(GE(VALUE(MID(身份证号,11,4)),823),LE(VALUE(MID(身份证号,11,4)),922)),\"处女座\",IF(AND(GE(VALUE(MID(身份证号,11,4)),923),LE(VALUE(MID(身份证号,11,4)),1023)),\"天秤座\",IF(AND(GE(VALUE(MID(身份证号,11,4)),1024),LE(VALUE(MID(身份证号,11,4)),1122)),\"天蝎座\",IF(AND(GE(VALUE(MID(身份证号,11,4)),1123),LE(VALUE(MID(身份证号,11,4)),1221)),\"射手座\",IF(AND(GE(VALUE(MID(身份证号,11,4)),120),LE(VALUE(MID(身份证号,11,4)),218)),\"水瓶座\",IF(AND(GE(VALUE(MID(身份证号,11,4)),219),LE(VALUE(MID(身份证号,11,4)),320)),\"双鱼座\",\"摩羯座\"))))))))))),\"\")","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":74,"sticky":null},"to":{"line":0,"ch":80,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":120,"sticky":null},"to":{"line":0,"ch":126,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":152,"sticky":null},"to":{"line":0,"ch":158,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":198,"sticky":null},"to":{"line":0,"ch":204,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":230,"sticky":null},"to":{"line":0,"ch":236,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":276,"sticky":null},"to":{"line":0,"ch":282,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":308,"sticky":null},"to":{"line":0,"ch":314,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":354,"sticky":null},"to":{"line":0,"ch":360,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":386,"sticky":null},"to":{"line":0,"ch":392,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":432,"sticky":null},"to":{"line":0,"ch":438,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":464,"sticky":null},"to":{"line":0,"ch":470,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":510,"sticky":null},"to":{"line":0,"ch":516,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":542,"sticky":null},"to":{"line":0,"ch":548,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":589,"sticky":null},"to":{"line":0,"ch":595,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":622,"sticky":null},"to":{"line":0,"ch":628,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":669,"sticky":null},"to":{"line":0,"ch":675,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":702,"sticky":null},"to":{"line":0,"ch":708,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":749,"sticky":null},"to":{"line":0,"ch":755,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":781,"sticky":null},"to":{"line":0,"ch":787,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":827,"sticky":null},"to":{"line":0,"ch":833,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":859,"sticky":null},"to":{"line":0,"ch":865,"sticky":null},"value":"textField_ksfyitkm","invalid":false}],"isCmData":true}
- IF (判断条件,结果为 true 的返回值, 结果为 false 的返回值)
- LEN(text):返回文本字符串中的字符个数
- AND(A, B, …):同时满足 A、B…
- MID(A,B,C):在 A 字符串中,从第 B 位开始取出 C 个字符
- VALUE():把 MID 函数取出的字符串转换成数字
- GE(value1,value2):value1 大于等于 value2 返回 true,支持数字,日期
- LE(value1,value2):value1 小于等于 value2 返回 true,支持数字,日期
计算星座
2. 案例演示
自动计算星座视频演示
3. 更多身份资料提取欢迎阅读文档👇:
宜搭为了更好的优化宜搭使用手册内容和质量,占用您3-5分钟时间,辛苦填写一下文档反馈问卷。文档反馈问卷是匿名提交,同时问卷信息仅用于宜搭文档体验反馈收集,感谢您对宜搭的支持!
--------------------获取宜搭最新信息,欢迎关注我们--------------------
本文档对您是否有帮助?