Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inserting date into sql or firebird;What is .t. value in
Message
From
08/10/2005 09:18:49
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
08/10/2005 09:10:54
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
01050571
Message ID:
01057437
Views:
9
>Thanks for your replies Cetin :)
>
>I was referring to the functions fbtos() and the function that
>would have used the return string below:
> RETURN "'" + TRANSFORM(dtoc(m.tdDate,1), "@R 9999/99/99")
>
>Both returns string value representing dates as : '9999/99/99'
>
>However i've found out the culprit. Firebird do accept date as '01/01/2005',
>but i've overlook other possible causes for the error. I've discovered through
>trial-and-error that the cause of the error is that firebird gets confused
>when the field name is date.
> ?sqlexec(nHandle,"insert into table1 (date) values ('01/01/2005')")
> returns -1
>but
> ?sqlexec(nHandle,"insert into table1 (tdate) values ('01/01/2005')")
>returns 1
>who would have thought? it's quite queer for firebird to get confused with
>such an often-used field. I've just tried SQL Server 2005 Express and all works just fine..
>
>Thanks again for your inputs

Everyone dealing with databases should have thought:) date is a reserved word and we never thought you were writing your actual code. In SQL server such keywords are supported via quoted identifiers and angle brackets. ie:
myDate = {^2005/1/1}
?sqlexec(nHandle,"insert into table1 ([date]) values (?m.myDate)")
Again and again I say do not send your dates as formatted strings. OK with 1/1/2005 FB accepts it and is no problem. But what if you send 1/2/2005? Is it Jan 2,2005 or Feb 1,2005? Depending on settings is not very good.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform