Mysql datetime insert format|Mysql time insert format

Date time insert format in mysql
Simple datetime format
select date_format(now(),'%Y-%m-%d %r');
Result:
Insert format:

Example:
INSERT INTO BATCHMAS(Code,LOCATIONCODE,NAME,SHORTNAME,ACTIVE,CREATEDDATETIME,USERID,MORNINGSTARTTIME)  
VALUES(7,0,0,0,0,NOW(),0,DATE_FORMAT(NOw(),'%Y-%m-%d %H:%i:%s'));

Insert Result:
Select Result:
Example time insert procedure :
CREATE PROCEDURE SPBATCHMAS(  
 $MODE         TINYINT UNSIGNED,  
 $MORNINGSTARTTIME time)
BEGIN   
  START TRANSACTION;
  IF $MODE =0  
    THEN  
    
      INSERT INTO BATCHMAS(MORNINGSTARTTIME)  
      VALUES($MORNINGSTARTTIME);
  END IF;       
  IF $ERR<>0 THEN 
    ROLLBACK;
  ELSE 
    COMMIT;
  END IF; 
 END

Post a Comment

0 Comments