Paradox: Query a Date column + a Time column as a DateTime

Austin Salonen picture Austin Salonen · Jun 25, 2009 · Viewed 8.8k times · Source

First off, I'm a Paradox newbie.
Secondly, I'm querying a database of a third-party software package and cannot change the schema.

I have two fields simply named "Date" and "Time" that I'd like to query as a DateTime (from my MS SQL experience).

Is this possible?

I've tried several queries and, when the command is valid, I get "Data type mismatch in criteria expression."

Also, this would be from a Paradox database from about 1999-2000 if that makes any difference.

EDIT: Even a simple string concatenation of the fields would a great help because I could handle that in code.

EDIT: In response to a.i.breveleri's answer. I get this message:

ERROR [42000] [Microsoft][ODBC Paradox Driver] Syntax error (missing operator) in query expression 'CAST(m.DateComplete AS TIMESTAMP) - CAST([1/1/3000] AS TIMESTAMP) + CAST(m.TimeComplete AS TIMESTAMP)'.

When I run this query:

select distinct 
  CAST(m.DateComplete AS TIMESTAMP) - 
  CAST("1/1/3000" AS TIMESTAMP) + 
  CAST(m.TimeComplete AS TIMESTAMP)
from Mean m 

Answer

Eugene Yokota picture Eugene Yokota · Jun 25, 2009
 SELECT CAST(f.DateColumn AS VARCHAR(20)) + ' ' + CAST(f.TimeColumn AS VARCHAR(20)) 
 FROM Foo f

That gives you the concatenated string.

 SELECT CAST(CAST(f.DateColumn AS VARCHAR(20)) + ' ' + CAST(f.TimeColumn AS VARCHAR(20)) AS TIMESTAMP) As FooTime
 FROM Foo f

gives you the combined time.