In Delphi, determine whether a user has a book that has expired.

Source: Internet
Author: User
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.