mysql - Return to default value after field equals zero -
so need in trying make database field it's default 7 , each day minuses 1 until 0 day count starts again 7. possible? if how?
select 7 - abs(0-dayofweek(now()))
work.
of course, since there 7 days in week, go 7,6,5,4,3,2,1,7. if want 0 indexed, use select 6 - abs(0-dayofweek(now()))
6,5,4,3,2,1,0,6.
i've interpreted question liberally, however. if want count 8 days (7,6,5,4,3,2,1,0,7), want select 8 - (to_days(now())%8)
.
Comments
Post a Comment