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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using SQL against Paradox ot get current date ?

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
From within an SQL statement against SQL Server I'm able to get the current date by using :
SELECT GETDATE() FROM TABLE1
Is there an equivalent bit of syntax that I can use to pull the same trick against PARADOX ?
I've failed attempting the obvious....
Any help would be appreciated.
Steve
 
StevenK,

I've fiddled with this for about an hour now and tried various ways to do this using just SQL tokens. It appears that Local SQL doesn't provide a function (or keyword) that returns the current date.

You best best is to pass the current date as a parameter to your query. If you're using SQL, I'd use a SQL expression to accomplish this. For example:

Code:
method pushButton(var eventInfo Event)
var
   db      Database
   sqlVar  SQL
   tv      TableView
endVar

const
   ANS = ":PRIV:ANSWER.DB"
endConst

   db.open()
   sqlVar = SQL

   select *
   from "datetest.db" d
   where
      d."Date" = ~( "\"" + string( date() ) + "\"" )

   endSQL
   if not SQLVar.executeSQL( db, ANS ) then
      errorShow( "oops" )
   else
      tv.open( ANS )
   endIf

endMethod

If memory serves, you're actually using Delphi (and, if so, should have posted the question in that forum), so the above code won't help much.

However, you should be able to use a query parameter to pass the current date into the query. Something like this should work:

Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
   with Query1 do
   begin
      if active then close;
      Params[0].AsDate := Sysutils.Date;
      Active := TRUE;
   end;
end;

The SQL statement attached to Query1 is:

Code:
select 
   *
from 
   "datetest.db" d
where
   d."Date" = :qpCurrentDate

Now, you can refer to the parameter in different ways, but this at least shows the approach I'd probably use.

I'll admit that it's not ideal, but it seems to be the best way to approach the problem at this point.

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top