Distinct with timestamp and miliseconds

distinctquerytimestamp

How can I perform a distinct when the system displays millisecond in my timestamps? I just need the date.

My query is like this:

select distinct orders.client_po, 
                orders.order_code, 
                orders.created_at, 
                carts.checkout_at 
            from orders
 left outer join carts on carts.code = orders.cart_id

carts.checkout_at is the same for all my orders but orders.created_at can be different. Some orders can be created the next day, the next minute and I want to know that but when they are created during the same second I get too much duplicate information.

Format of my dates is timestamp without time zone.

Best Answer

I found a workaround with

select distinct orders.client_po, orders.order_code, to_char(orders.created_at, 'DD-Mon-YYYY') , to_char(carts.checkout_at, 'DD-Mon-YYYY') from orders
left outer join carts on carts.code = orders.cart_id