我有一个要求,我不能在MySql中创建任何新程序或修改现有的任何新程序。我需要编写代码,其中所有日期都在日期范围内的相应模式(下面指定)中发布。为此,我尝试了所有循环,但无法弄明白。这就是写的:
SET @Startdate ='2016-03-10';
WHILE @Startdate< CURDATE()DO
SELECT DATE_FORMAT(@Startdate,'%Y%m%e') DateID,
DATE_FORMAT(@Startdate,'%e/%m/%Y') DDFulldate,
DATE_FORMAT(@Startdate,'%m/%d/%Y') MMFullDate,
DATE_FORMAT(@Startdate,'%d') DAY_OFMONTH,
DATE_FORMAT(@Startdate,'%W') DAY_NAM,
DATE_FORMAT(@Startdate,'%w') DAY_OFWEEK,
DATE_FORMAT(@Startdate,'%b') MONTH_NAME,
DATE_FORMAT(@Startdate,'%M') MonthFullName,
DATE_FORMAT(@Startdate,'%c') MONTH_NUMBER,
QUARTER(@Startdate) QUARTER_NAME,
DATE_FORMAT(@Startdate,'%Y') YEAR_NAME,
DATE_FORMAT(@Startdate,'%m%Y') MonthYear
SET @Startdate =DATE_ADD(@Startdate,INTERVAL 1 DAY);
END WHILE;
已附加所需的结果集。Desired Sample result