The date is entered by the user through a text field in a form, and is in the end used in an xml-file. The logic for the application that in turn will read this file, expects a "YYYY-MM-DD"-format. The way I see it, conversion can be done in two ways: 1) Assign the date-field value in the form to a proper formatted cell in Excel, and then fetch when generating the export file or 2) Format the date in a variable in the code.
I have tried both. 1) The value from the form, stays in the same format as in VB when stored in an Excel-cell. If I activate the cell, and press Enter, it gets the correct format. As for 2), I have tried the "format"-code mentioned above, but I get Compile-error, stating that an "=" is expected in the end.
This is my code that involves the date so far:
Dim InvoiceDate As Date
'Format(Invoicedate, "YYYY-MM-DD")
InvoiceDate = fldInvoiceDate.Value
As for the format part, I have seen it elsewhere in a somewhat different way:
Format(Date, "YYYY-MM-DD") = InvoiceDate
Using this code, I got an error-message stating that an object was required.
Hope this is enough info.