Display date with timestamp in sqlplus
If you have column of type date in your table,
and if you want to query it in sqlplus like below, it will only display the date without timestamp.
select salesdate from sales;
Output:
SALESDATE
---------
31-DEC-13
31-AUG-13
9 rows selected.
In order to display date with timestamp also, you have to use to_char() and format the output as below
select to_char(salesdate,'dd/mm/yyyy hh24:mi:ss') from sales;
TO_CHAR(SALESDATE,
-------------------
31/12/2013 06:30:00
31/08/2013 06:30:00
9 rows selected.
If you have column of type date in your table,
and if you want to query it in sqlplus like below, it will only display the date without timestamp.
select salesdate from sales;
Output:
SALESDATE
---------
31-DEC-13
31-AUG-13
9 rows selected.
In order to display date with timestamp also, you have to use to_char() and format the output as below
select to_char(salesdate,'dd/mm/yyyy hh24:mi:ss') from sales;
TO_CHAR(SALESDATE,
-------------------
31/12/2013 06:30:00
31/08/2013 06:30:00
9 rows selected.
No comments:
Post a Comment