Determine whether a user has a book that has expired in Delphi. Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiDB/html/delphi_20061225162553113.html
I used BDE to connect to the database. I want to determine whether the users in the database table have borrowed books that have not been returned yet. How should I write them ~~ (I used query, table, database, DBGrid, and datasource. The table has been borrowed and expired in over 30 days)
Use query, and then query select * From yourtable where borrowdate + 30> = getdate to display the result in DBGrid!
Borrow time: tdatetime; // if it is another type, it needs to be converted, for example, borrow time: = vartodatetime ('2017-12-2 ')
If now <incday (borrow time, 30) then
Showmessage ('in borrow instance ')
Else
Showmessage ('expired! ');
Forget to say:
1. You need to reference the sysutils unit (uses sysutils ;)
2. Replace <with <=
Select * From yourtable where borrowdate + 30> = how to write the borrowdate and getdate formats in getdate ~~ Can you give an example ~~
How to Write getdate ~~ I want to getdate the current system time ~~ The format is yyyy-mm-dd.
With query2 do
Begin
Close;
SQL. Clear;
SQL. Add ('select debit card number, borrow date from lend where debit card number =: qame and borrow date> current time + 30 days ');
Parambyname ('qame'). asstring: = edit14.text;
Open;
Showmessage (inttostr (recordcount ));
End;
How can I write data in the current time + 30 days ~~
Let me answer the question for the first floor:
'Select debit card number, borrow date from lend where borrow card number =: qame and borrow date> dateadd ("D", 30, current date )'
I have not tried it ~~ Test it together ~~ In fact, check the VBScript function book to find such a function.
I have tested it. You can!
SQL. text: = 'select * from lend where date> dateadd ("D", 30, now) ';
use or use <, it is up to the landlord to decide! Anyway, dateadd ("D", 30, now) is equal to today + 30 days!
~~ Note that the unit is day (d)
the landlord encounters a problem where such SQL statements are not written. First, you can find SQL related information from the Internet, you can find the VBScript function.