Need help to return the last date with windev

Startbeitrag von Nadiawindev am 28.04.2017 08:30

hello everybody,
I have a field in a table with different maintenance dates how to return the last maintenance date for the same client, I used the HLitSearchLast function but it returns the last line of these dates and I want the last date Whose customer has taken a maintenance, Thanks in advance for your help

Antworten:

Hi, a simple solution would be to Hfilter the file for this single customer first before reading the last date of maintenance! Or a key in the file for customer# + maintenance date and HReadSeekLast(FilName, KeyName, Customer# + "29991231", hgeneric) ... symbolic annotation of a composite key.

Personally, I do not use PC Soft's composite keys but create mine within a trigger procedure like NumToString(YourCustomerNum,"06d")+"29991231"). The result is a simple string ...

von GuenterP - am 28.04.2017 08:44
Thank you very much for your help Guenter Predl, but I managed to do it by used of a request it was simpler for me than the use of the function Hfilter.

Best regards,
Nadia

von Nadiawindev - am 28.04.2017 13:13
Hi Nadia,

if you are convenient with SQL, it's easy and comfortable to use a query, even if you have no Key on date field (maybe slower, but the database is doing it for you). Would look like:


select customer_number, max(maintenance_date)
from your_databasefile
where customer_number =
group by customer_number

When I started to use MSSQL as my database, I started to learn 'SQL syntax' and found it very useful. By the way, you can very easily test the query using 'wdmap' on every single file or something like 'SQL Management studio' without the Need to compile and start your application with all the necessary menu openings ...

When the test is ok, then I copy the query to my app, making a last test.
Even when encountering Problems later, I just copy the query from the app back to the tool for easily finding the Problem.

And last, but not least, if using just Standard Syntax, it will work for nearly every type of database.

Regards

Erik

von Erik Schwarz - am 29.04.2017 08:14
Hi

hreadseeklast() on the date field ?


regards

von Allard - am 01.05.2017 10:39
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.