获取本月月初的日期:
select MDY(MONTH(sysdate),1,year(sysdate)) from sysmaster:sysdual
获取本月月末的日期:
select MDY(MONTH(add_months(sysdate,1)),1,year(add_months(sysdate,1)))-1 from sysmaster:sysdual
取日期的当年天数:
CREATE FUNCTION day_of_year(dt date)
RETURNS integer WITH(NOT VARIANT)
RETURN(1 + dt - MDY(1, 1, YEAR(dt)) );
END FUNCTION;
年中的周函数:
CREATE FUNCTION week_of_year(dt date)
RETURNS integer WITH(NOT VARIANT)
DEFINE day1 date;
DEFINE nbdays int;
LET day1 = MDY(1, 1, YEAR(dt));
LET nbdays = dt - day1;
RETURN 1 + (nbdays + WEEKDAY(day1)) / 7;
END FUNCTION;
未完,待补充