Getting the wrong value using .text

I’m using this macro for a test I want to make, but it keep giving me the wrong number, instead of 24/09/2020 that is on the “datDate” field, it gives me 31/01/2024, it only gives me the right number when I change it, but when I do it, it sets a new “default” date to the date I just defined, and then even if the text in the next record is different, it returns me the old one. Why?

sub testing
    dim forms as object
    dim test as string
    forms = ThisComponent.DrawPage.Forms.getByName("MainForm")
    test = forms.getByName("datDate").text
    msgbox(test)
end sub

Try:

test=CdateFromUnoDate(forms.getByName("datDate").date)

If I click on a date-field, which shows content from a database file, the property “Text” will be empty.
You could only get the data, which has been saved, by the struct Date (or CurrentValue):

testDay = forms.getByName("datDate").Date.Day

… and the same for month an year.
You will get the whole date by

testDate = forms.getByName("datDate").BoundField.String

You will see the data formatted as SQL-format: YYYY-MM-DD

If you change the date you will get a value in property “Text”. This will be shown as it is shown in the form. But the saved string in BoundField will always be the same old value, because it will show the value, which has already been saved in the database.

Why it worked before though? Can’t explain when it just stopped

If it ever works before: The changing for date fields to save the value in a struct has been in LO 4.1.2.