0

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.

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.