Board index » delphi » Problem with SQL-query, update and insert date values

Problem with SQL-query, update and insert date values

Hi,
I wonder if somebody can help me with my problems
during the use of SQL-Queries. The problem I have
is how the syntax should look like when I want to
INSERT or UPDATE a column in a Paradox table that
is specified as DATE. A string needs ' to show
that it is a string, an integer need nothing.
What does a date column type need when a SQL
statement is typed in the SQL-query?
An example to show what I mean:
Update customer
set custno = 4,
     customername = 'Data Inc.',
     date = ???

How should the correct SQL-statement look like to
make this work. I've tried with ' and " round the
date value but nothing works....

Best regards
Fredrik

 

Re:Problem with SQL-query, update and insert date values


Quote
Fredrik Berglund wrote in message

<01bdaea5$1be262a0$135df...@win95.swipnet.se>...
<snip>

Quote
>An example to show what I mean:
>Update customer
>set custno = 4,
>     customername = 'Data Inc.',
>     date = ???

>How should the correct SQL-statement look like to
>make this work. I've tried with ' and " round the
>date value but nothing works....

Did you use the a full four digit year in US format?
Example: SET Date1 = '12/31/1998'

Date is also a reserved word in SQL. Did you fully qualify it and put it in
quotes?
Example: SET "Table.DB"."Date" = '12/31/1998'

        -- Kirk

Re:Problem with SQL-query, update and insert date values


Try this:
//  in code
Update customer
set custno = 4,
     customername = 'Data Inc.',
     customer."date" = '+DateTimeToStr(YourDate)

//  in TQuery
Update customer
set custno = 4,
     customername = 'Data Inc.',
     customer."date" = :MyDate

in the Params section Declare MyDate as DateTime and then in your set the
param to whatever datetime you wish to send it.

Hope this helps!

Quote
Fredrik Berglund wrote in message

<01bdaea5$1be262a0$135df...@win95.swipnet.se>...
Quote
>Hi,
>I wonder if somebody can help me with my problems
>during the use of SQL-Queries. The problem I have
>is how the syntax should look like when I want to
>INSERT or UPDATE a column in a Paradox table that
>is specified as DATE. A string needs ' to show
>that it is a string, an integer need nothing.
>What does a date column type need when a SQL
>statement is typed in the SQL-query?
>An example to show what I mean:
>Update customer
>set custno = 4,
>     customername = 'Data Inc.',
>     date = ???

>How should the correct SQL-statement look like to
>make this work. I've tried with ' and " round the
>date value but nothing works....

>Best regards
>Fredrik

Other Threads