pmod(int a, int b)
pmod(double a, double b)
返回a除b的余数的绝对值
Sql实现如下:
select
case
when pmod(datediff(current_date,'2018-01-01'),7) = 0 then concat(current_date,'(周一)')
when pmod(datediff(current_date,'2018-01-01'),7) = 1 then concat(current_date,'(周二)')
when pmod(datediff(current_date,'2018-01-01'),7) = 2 then concat(current_date,'(周三)')
when pmod(datediff(current_date,'2018-01-01'),7) = 3 then concat(current_date,'(周四)')
when pmod(datediff(current_date,'2018-01-01'),7) = 4 then concat(current_date,'(周五)')
when pmod(datediff(current_date,'2018-01-01'),7) = 5 then concat(current_date,'(周六)')
when pmod(datediff(current_date,'2018-01-01'),7) = 6 then concat(current_date,'(周日)')
else '-' end as today_date
from table_tmp
遇到的pmod问题详见:
https://blog.csdn.net/weixin_40983094/article/details/113502932