Handling Date columns in SQL

40 Views Asked by At

I am trying to get some data from a SQL table. After reading the date the output looks like this

ID      BEGIN_DT                END_DT                   PX_LAST
----------------------------------------------------------------
13442   1900-01-01 00:00:00.000 1900-01-31 00:00:00.000      1

The data type shown in the output is DATE.

Can you let me know how to remove the timestamp 00:00:00.000 from the output?

1

There are 1 best solutions below

0
Isolated On

In oracle, you can trunc() the timestamp or convert to char.

select 
  current_timestamp,
  trunc(current_timestamp) as trunc_dt, 
  to_char(current_timestamp, 'YYYY-MM-DD') as char_dt
from dual
CURRENT_TIMESTAMP TRUNC_DT CHAR_DT
24-AUG-23 18.49.48.795426 +01:00 24-AUG-23 2023-08-24