Search code examples
delphidelphi-xe2delphi-7delphi-2010delphi-xe

Display how many days since last visit


I have a query that displays hotel guests stay data (START_DATE,END_DATE). I would like a label to display how many days passed since guests last visit relative to today. So,example, if guest left on the 29.3.2013 and I view the data, I would like the label to tell me : Last visit "2" days ago.


Solution

  • DaysBetween works here, too, just like it works in your last question.

    Label1.Caption := Format('Last visit %d days ago', 
                        [DaysBetween(Date, Qry.FieldByName('END_Date').AsDateTime)]);