Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Combine date and time
Sat, Jan 6 2018 11:11 AMPermanent Link

Hershcu Sorin

Hi
I want to combine a Date and a Time field to one.
Something like:
"select MyDate + MyTime as MyDateTime
from..."

What is the right command?
Thanks Sorin
Sat, Jan 6 2018 6:17 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Sorin,

Try this:

SELECT MyDate + (MyTime - TIME '0') FROM ...

The expression (MyTime - TIME '0') is going to convert the original TIME value into an INTERVAL, that is after added to the DATE, resulting in a TIMESTAMP.

--
Fernando Dias
[Team Elevate]
Sun, Jan 7 2018 3:56 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Hershcu


I like Fernando's approach - its sneaky.

There is always the traditional CAST approach

CAST(CAST(MyDate AS VARCHAR(10))+' '+CAST(MyTime  AS VARCHAR(10)) AS TIMESTAMP)

Roy Lambert
Mon, Jan 8 2018 4:04 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Fernando,

<< Try this: >>

Roy is right - that *is* sneaky... Wink

Tim Young
Elevate Software
www.elevatesoft.com
Image