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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章