mysql获取当前年月 mysql中replace into用法

发布时间 2023-04-22 19:07:59作者: binbinx

mysql获取当前年月

 
//1.获取年月日 时分秒 

select SYSDATE() AS '年月日 时分秒';
2020-07-02 16:36:17
//2.获取(年月日)

select DATE(CURDATE()) as '年月日';
select CURDATE() as '年月日';
select current_date AS '年月日';
 
2020-07-02
//3.获取(时分秒):

select time(SYSDATE()) AS '时分秒';
select CURtime() AS '时分秒';

16:36:17
//4.获取年份

select YEAR(CURDATE()) AS '年';
select YEAR(SYSDATE()) AS '年';
select year(CURRENT_DATE) AS '年' ;
 
2020
//5.获取月份

select MONTH(CURDATE()) AS '月';
select MONTH(SYSDATE()) AS '月';
select month(CURRENT_DATE) AS '月';

7
//6.获取日期中的日 

select day(CURRENT_DATE) AS '日';
select day(CURDATE) AS '日';
select day(SYSDATE) AS '日';

3
//7.获取当年一月份

select CONCAT(YEAR(CURDATE()),'-','01');
 
2020-07
//8.获取当前系统小时:

select HOUR(SYSDATE()) AS '系统小时';

16
//9.获取当前系统分钟:

select MINUTE(SYSDATE()) AS '系统分钟';

36
//10.获取当前系统秒:

select SECOND(SYSDATE()) AS '系统秒';

17
//11.获取当前系统毫秒:
select MICROSECOND(SYSDATE()) AS '系统毫秒';
0

mysql中replace into用法

 
 
<insert id="saveOrUpdatePayinfo" parameterType="com.bill.invoice.entity.BusBillPayinfo">
        replace into bus_bill_payinfo
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id!=null"> ID, </if>
            <if test="sysOrgCode!=null"> SYS_ORG_CODE, </if>
            <if test="billinfoid!=null"> BILLINFOID, </if>
            <if test="bankcode!=null"> BANKCODE, </if>
            <if test="billcode!=null"> BILLCODE, </if>
            <if test="trandamt!=null"> TRANDAMT, </if>
            <if test="tranddate!=null"> TRANDDATE, </if>
            <if test="returnamt!=null"> RETURNAMT, </if>
            <if test="returndate!=null"> RETURNDATE, </if>
            <if test="whendate!=null"> WHENDATE, </if>
            <if test="createBy!=null"> CREATE_BY, </if>
            <if test="createTime!=null"> CREATE_TIME, </if>
            <if test="updateBy!=null"> UPDATE_BY, </if>
            <if test="updateTime!=null"> UPDATE_TIME, </if>
        </trim>
        VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id!=null"> #{id}, </if>
            <if test="sysOrgCode!=null"> #{sysOrgCode}, </if>
            <if test="billinfoid!=null"> #{billinfoid}, </if>
            <if test="bankcode!=null">  #{bankcode}, </if>
            <if test="billcode!=null">  #{billcode}, </if>
            <if test="trandamt!=null">  #{trandamt}, </if>
            <if test="tranddate!=null">  #{tranddate}, </if>
            <if test="returnamt!=null">  #{returnamt}, </if>
            <if test="returndate!=null">  #{returndate}, </if>
            <if test="whendate!=null">  #{whendate}, </if>
            <if test="createBy!=null">  #{createBy}, </if>
            <if test="createTime!=null">  #{createTime}, </if>
            <if test="updateBy!=null">  #{updateBy}, </if>
            <if test="updateTime!=null">  #{updateTime}, </if>
        </trim>
    </insert>