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.

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
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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