Convert Date and Time to DateTime

Paulomongo

New Member
Hello,

I have two fields in my database

DT."tx-date" - Type Date
DT."tx-time" - Type Varchar

I want to convert these two fields into one so that I can find the maximum entry in my database for the current day, I have been looking at the cast function where I can convert the DT."tx-time" to a time format however now stuck on how to concat the fields together to convert to datetime.

Please help
 

rstanciu

Member
something like this ?

Code:
DEFINE VARIABLE tx-date AS DATE NO-UNDO.
DEFINE VARIABLE tx-time AS CHARACTER NO-UNDO.
DEFINE VARIABLE dt AS DATETIME NO-UNDO.
tx-date = TODAY.
tx-time = "15:38:05".
dt = DATETIME(STRING(tx-date,"99-99-9999") + " " +  tx-time).
MESSAGE dt VIEW-AS ALERT-BOX.
 

Paulomongo

New Member
Hi,

I am running this through via a SQL command in Crystal reports connecting via ODBC, this is what I have so far, not sure whether the above will work within my select statement.

SELECT
DT."debt-code",
DT."tx-date",
DT."tx-time"
cast(DT."tx-time" as time)
FROM
"PUB"."debt-trans" DT
WHERE
DT."debt-code"='201546553' AND DT."tx-date"={d '2011-04-20'}
 

medu

Member
Re: MANGA Comics and Anime Community

how does the data in your 'time' field look like, since it's a varchar it can be pretty much anything :)
 
Top