Question

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 
Was it helpful?

Solution

 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.

OTHER TIPS

QBE query:

Query
ANSWER: :PRIV:ANSWER.DB

test.db | Date | Time                         | 
        | _x   | _y, calc _x+_y as "DateTime" | 

EndQuery

SQL query:

SELECT DISTINCT
    CAST(D0."Date" AS TIMESTAMP) -
    CAST("1/1/3000" AS TIMESTAMP) +
    CAST(D0."Time" AS TIMESTAMP)
FROM 
    "test.db" D0

-Al.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top