Can anyone explain this?

When looking for transactions based on timestamp in e.g. 2017 you can for instance do it like this:

...where timestamp >= to_date('2017','YYYY')
or
...where timestamp >=to_date('01.01.2017','DD.MM.YYYY')

Why does these two expressions return different number of transactions? In my case the latter returns appox. 8 times as many. Is this an error in Oracle SQL or is it something I have missed?

Thx!

Brgds
IVer Erling Årva, Oslo
0
LVL 26

Comment

by:Alex [***Alex140181***]
Have you ever tried to check via:
select to_date('01.01.2017', 'DD.MM.YYYY'),
       to_date('2017', 'YYYY')
  from dual;

Open in new window

results: 01.01.2017      01.06.2017
0

Author Comment

by:Iver Erling Arva
Oh! What can possibly be the reason for this? Very strange if you ask me, but thanks for your help! I will make sure not to make that mistake again :-)

Brgds
IVer
0
LVL 26

Comment

by:Alex [***Alex140181***]
I don't think this is a bug, I suppose it's just the default behavior if you omit some time parts. I just can't find any evidence within the official docs. Maybe some other Oracle expter may help in finding that reference?!
0

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month