code: func builtinDayOfMonth(args []types.Datum, ctx context.Context) (d types.Datum, err error) {
  	// TODO: some invalid format like 2000-00-00 will return 0 too.
  	d, err = convertToTime(ctx.GetSessionVars().StmtCtx, args[0], mysql.TypeDate)
  	if err != nil || d.IsNull() {
  		return d, errors.Trace(err)
  	}
  
  	// No need to check type here.
  	t := d.GetMysqlTime()
  	if t.IsZero() {
  		d.SetInt64(int64(0))
  		return d, nil
  	}
  
  	d.SetInt64(int64(t.Time.Day()))
  	return d, nil
  }
docs: // See http://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_dayofmonth