Toad World® Forums

Truncate Date results

Hi everyone, I’m very new at SQL queries…I’m learning as I go.

I know this should be easy but every day I’m making improvement.

I built this query and my date results include time, minutes second. I’d like to get rid of that.

This is what I have as my date range and the returned values.

where e.start_date_time >=to_date(‘2014-01-01’, ‘YYYY-MM-DD’) and e.start_date_time <=to_date(‘2014-12-31’, ‘YYYY-MM-DD’

These are the result for e_start_date_time

2014/01/01 1:53:33 PM

How do I truncate to YYYY/MM/DD?

Where do I go from there?

Thanks

You were so close!

You need to TRUNC (datetime_column) in your SELECT to lose the time part.

HTH

Cheers,

Norm [ TeamT ]

On 15 September 2015 06:38:25 BST, Samwize1976 bounce-Samwize1976@toadworld.com wrote:

Truncate Date results

Thread created by Samwize1976
Hi everyone, I’m very new at SQL queries…I’m learning as I go.

I know this should be easy but every day I’m making improvement.

I built this query and my date results include time, minutes second. I’d like to get rid of that.

This is what I have as my date range and the returned values.

where e.start_date_time >=to_date(‘2014-01-01’, ‘YYYY-MM-DD’) and e.start_date_time <=to_date(‘2014-12-31’, ‘YYYY-MM-DD’

These are the result for e_start_date_time

2014/01/01 1:53:33 PM

How do I truncate to YYYY/MM/DD?

Where do I go from there?

Thanks

To reply, please reply-all to this email.

Stop receiving emails on this subject.

Or Unsubscribe from Toad for Oracle - General notifications altogether.

Toad for Oracle - Discussion Forum

Flag this post as spam/abuse.

Sent from my Android device with K-9 Mail. Please excuse my brevity.

Samwize1976 - typically wrap the date in your select list in a TO_CHAR with an appropriate mask e.g. TO_CHAR(e_start_date_time, ‘YYYY/MM/DD’). Assuming you are happy to have a character string in your result set and not a date.