Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database-independant conversion of text to date 1

Status
Not open for further replies.

foxdev

Programmer
Feb 11, 2000
1,995
US
One of my client's applications supports three different database servers, so it is important to create SQL commands that function identically in all of them.

One of my techniques is to use the ODBC scalar function Convert, which can convert (among other things) a character string to a date. I use this when building WHERE clauses for my SQL statements.

For example, say I have a control on a form where a user types in or selects a date, and this control uses a character-type value. When building my SQL statement, I can ensure this value is properly handled as a date on the server by using the ODBC Convert function thusly:

[tt]"post_dt={fn CONVERT('" + MyControl.Value + "', SQL_DATE)} "[/tt]

When the statement is eventually sent to the database via the ODBC driver, the driver sees the pair of curly braces {} and knows it needs to apply some processing. It then converts MyControl.Value to a date type appropriate to the currently-connected database. [sig]<p>Robert Bradley<br><a href=mailto: > </a><br><a href= - Visual FoxPro Development</a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top