Hi, I have 2 date fields in a Table, both correctly set to Date/Time values and formatted as UK dd/mm/yyyy. These work fine in Forms & Queries. However, in one query I have concatenated the two [Datefields] in a calculated field to display as a single column. (The two date fields ae mutually exclusive, i.e. there is never a date in both fields in the same record -hence combining into a single display column for the purposes of this particular query).
The concatenation is Expr1: [Datefield1]&[Datefield2] which works fine in that it does just what I want. However, when I try to Order by this field (Ascending) the field is sorted by dd, not dd/mm/yyyy.
Research has found the following:
Access can also misinterpret calculated date fields in queries, especially where the date format is not American and the field contains some Nulls. The obvious symptoms are that the field is left-aligned and sorted as strings.
The solution is to explicitly typecast all calculated date fields, e.g.:
DueDate: CVDate([InvoiceDate] + 30) (Note: CDate() fails on Null values, so CVDate() has more uses than the "compatibility" issue highlighted in the Access documentation.)
This appears to be exactly what is happening, the concatenated Field is left aligned, and sorted as a string.
I need to force access to read the concatenated field as a UK Date, dd/mm/yyyy, but I don't know how ?
I don't understand how to apply the above, Can anyone assist ?
I had hoped to force it to read as Date by inserting #_#, but this isn't working.(I've tried various permutations)
There doesn't appear to be a way to format individual Fields in the Query Design View ?
Thank you all in advance.
The concatenation is Expr1: [Datefield1]&[Datefield2] which works fine in that it does just what I want. However, when I try to Order by this field (Ascending) the field is sorted by dd, not dd/mm/yyyy.
Research has found the following:
Access can also misinterpret calculated date fields in queries, especially where the date format is not American and the field contains some Nulls. The obvious symptoms are that the field is left-aligned and sorted as strings.
The solution is to explicitly typecast all calculated date fields, e.g.:
DueDate: CVDate([InvoiceDate] + 30) (Note: CDate() fails on Null values, so CVDate() has more uses than the "compatibility" issue highlighted in the Access documentation.)
This appears to be exactly what is happening, the concatenated Field is left aligned, and sorted as a string.
I need to force access to read the concatenated field as a UK Date, dd/mm/yyyy, but I don't know how ?
I don't understand how to apply the above, Can anyone assist ?
I had hoped to force it to read as Date by inserting #_#, but this isn't working.(I've tried various permutations)
There doesn't appear to be a way to format individual Fields in the Query Design View ?
Thank you all in advance.