Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to work with 2 formatted dates, if I have TO_DATE('20160101' YYMMDD) and TO_DATE('20160104', YYMMDD) I would like to receive this output:

20160101
20160102
20160103
20160104

Is there a fast way to achieve this without using PL/SQL?

Thanks to all!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
170 views
Welcome To Ask or Share your Answers For Others

1 Answer

The format mask in to_date() must be enclosed within single quotes too.

To produce the output in string format you need to apply to_char() with the same format mask.

select to_char(to_date('20160101', 'YYYYMMDD') + level - 1, 'YYYYMMDD') as dt
from   dual
connect by level <= 1 + to_date('20160104', 'YYYYMMDD') - to_date('20160101', 'YYYYMMDD')
;


DT     
--------
20160101
20160102
20160103
20160104

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...