[html] view plain copy
- //时间原本格式:1970-01-01 20:50:00
- where之后的条件为自定义添加
- //转换为年月日
- select substr(from_unixtime(unix_timestamp(时间字段名称,'yyyy-MM-dd')),1,4) as 自定义字段名称
- from table where id = * group by substr(from_unixtime(unix_timestamp(时间字段名称,'yyyy-MM-dd')),1,4);
- 显示:1970-01-01
- //转换为年月
- select substr(from_unixtime(unix_timestamp(时间字段名称,'yyyy-MM-dd')),1,4) as 自定义字段名称
- from table where id = * group by substr(from_unixtime(unix_timestamp(时间字段名称,'yyyy-MM-dd')),1,7);
- 显示:1970-01
- //转换为年
- select substr(from_unixtime(unix_timestamp(时间字段名称,'yyyy-MM-dd')),1,4) as 自定义字段名称
- from table where id = * group by substr(from_unixtime(unix_timestamp(时间字段名称,'yyyy-MM-dd')),1,10);
- 显示:1970