Code problem. Using 'from datetime import datetime' leads to the problem: NameError: name 'datetime' is not defined.
This appears several times, anytime this commando is used.
meanwhile I found the problem. I typewrite the code on page 42 of the book "Rasperry Pi für Einsteiger" and saved the file in the /usr/pi folder with the name "datetime.py".
After renaming the filename the script works. Apparent the names of the files does not have the same name as in the /lib folder.
Thanks for your support.