我有一个查询,它返回给定年份的第二和第四个星期六,
WITH ALL_SATURDAYS AS
(SELECT TO_CHAR(TO_DATE('01012014','DDMMYYYY'),'WW') * (level) AS WEEK_NO,
NEXT_DAY(TO_DATE('01012014','DDMMYYYY') + (TO_CHAR(TO_DATE('01012014','DDMMYYYY'),'WW' ) * (level-1) * 7),'土') AS SATURDAY_DATE,
row_number() OVER (PARTITION BY TO_CHAR(NEXT_DAY(TO_DATE('01012014','DDMMYYYY') + (TO_CHAR(TO_DATE('01012014','DDMMYYYY'),'WW' ) * (level-1) * 7),'土'),'月') ORDER BY level) AS Pos
FROM DUAL
CONNECT BY level<= 52
ORDER BY 1
)
SELECT SATURDAY_DATE,POS FROM ALL_SATURDAYS WHERE POS IN (2,4) ORDER BY 1,2
它在其他系统中工作,但是当我执行此查询时,我的日语操作系统返回ORA-01821: date format not recognized
错误。
如何解决错误?
答案 0 :(得分:2)
将月
替换为MONTH
。日期时间格式元素始终为英语,即使结果可能是其他语言。
alter session set nls_date_language=japanese;
select to_char(date '2014-01-01', 'MONTH') month from dual;
Month
-----
1月