How to distinguish date at midnight from date w/o time in Oracle?

Posted by Swiety on Stack Overflow See other posts from Stack Overflow or by Swiety
Published on 2010-05-12T10:20:17Z Indexed on 2010/05/12 10:24 UTC
Read the original article Hit count: 142

Filed under:
|
|

I would like to distinguish date at midnight (i.e. '12/05/2010 00:00:00') from date without time specified (i.e. '12/05/2010').
This value is provided by user, sometimes it is only date which is important, sometimes it is date and time and later the application is expected to show the time only when it was explicitly provided. So for the following inputs I would expect the following outputs:

  • for '12/05/2010' I would expect '12/05/2010'
  • for '12/05/2010 09:23' I would expect '12/05/2010 09:23'
  • for '12/05/2010 00:00' I would expect '12/05/2010 00:00'

I know I can model it in two separate columns, date and time, but I was wondering was there any way of handling this in single date column?

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about date