×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Change DATE and also a TIMESTAMP to just a date as 'MM/DD/YYYY. Also, need dummy date when null

Change DATE and also a TIMESTAMP to just a date as 'MM/DD/YYYY. Also, need dummy date when null

Change DATE and also a TIMESTAMP to just a date as 'MM/DD/YYYY. Also, need dummy date when null

(OP)
Change DATE and also a TIMESTAMP to just a date 'MM/DD/YYYY'

Table1:
Example in the date field: 2013-03-28 22:14:44. Need to have it as 03/28/2013

Table1 if null: 01/01/1900

Table 2:

Example in the timestamp field in table2: 2010-01-02 00:00:00.000000. Need to have it as 01/02/2010

Help is very appreciated!

RE: Change DATE and also a TIMESTAMP to just a date as 'MM/DD/YYYY. Also, need dummy date when null

Check TRUNC() and NVL() functions in Oracle


---- Andy

There is a great need for a sarcasm font.

RE: Change DATE and also a TIMESTAMP to just a date as 'MM/DD/YYYY. Also, need dummy date when null

A date or timestamp column will always contain both calendar and time information. To remove the time information will set it to midnight. Also the internal structure will always stay the same. If you want it to be displayed in a different mask then do the following

1* select to_char(sysdate,'mm/dd/yyyy hh:mi.ss am') from dual
SQL> /

TO_CHAR(SYSDATE,'MM/DD
----------------------
08/12/2019 10:01.10 am

SQL> edit
Wrote file afiedt.buf

1* select to_char(trunc(sysdate),'mm/dd/yyyy hh:mi.ss am') from dual
SQL> /

TO_CHAR(TRUNC(SYSDATE)
----------------------
08/12/2019 12:00.00 am

If the date column is null then

select nvl(date_col,to_date('01/01/1900','mm/dd/yyyy') from my_table

To display a date as month/day/year

SQL> select to_char(sysdate,'MM/DD/YYYY') FROM DUAL;

TO_CHAR(SY
----------
08/12/2019





Bill
Lead Application Developer
New York State, USA

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close