0

考虑具有列EffectiveDate的表DateDetails。我想写一个更新查询,这样:

  if effectiveDate > "first day of the month" then
         ->set it to "first day of the month"

就像是 :

update DateDetails
set effectiveDate = (start of the month)
where effectiveDate > (start of the month)

有效日期是日期类型。日、月、年也可以是任意的:12-JAN-2013 或 24-DEC-2056
我该怎么写?

4

2 回答 2

1
update DateDetails
set effectiveDate = DATE_FORMAT(start_date ,'01-%b-%Y')
where effectiveDate > start_date;

将所有日期更改为生效日期当月的第一天

update DateDetails
set effectiveDate = DATE_FORMAT(effectiveDate ,'01-%b-%Y');
于 2013-07-18T13:37:33.027 回答
0
update DateDetails
set effectiveDate = DATE_FORMAT(effectiveDate, '01-%b-%Y')
where effectiveDate > DATE_FORMAT(effectiveDate, '01-%b-%Y');
于 2013-07-18T14:01:22.347 回答