Forum Discussion
juhanik
Jun 11, 2024Copper Contributor
Switch function with different date formats in Access SQL
Hi. First time trying to use switch function to combine multiple queries to one. For some reason "DateValue" function overrides "DatePart" function in switch clause and gives me wrong format for ...
Jun 11, 2024
Hi,
String concatenation and DateValue are not reliable ways of obtaining a valid date. If you need to save and use the date parts in this way, you should first create a valid date using the DateSerial function and then apply the other date functions to it. Like this:
DateValue([PK112.C] & ...) --> DateSerial([A], [B], [C])
DatePart("ww", ([PK112.C] & ...) --> DatePart("ww", DateSerial([A], [B], [C]))
Servus
Karl
****************
Access Forever
Access News
Access DevCon
Access-Entwickler-Konferenz AEK