天天看點

pgsql -- to_char

工具:mybatis+pgsql

詳見:pgsql官方文檔

含義:to_char 是把日期或數字轉換為字元串

表結構:

create table user(
	id varchar(32) not null default sys_guid(),
	username varchar(25) not null,
	birthday timestamp not null default now()
)
           

案例 – timestamp轉成年月日的格式

dao層

List<User> list(); 
           

sql

<select id = "list"  resultType = "com.test.dto.User">
	select  username,
	        to_char(birthday,'YYYY-mm-dd')
	  from  user
</select>
           

繼續閱讀