- Local time
- Today, 17:09
- Joined
- Jul 9, 2003
- Messages
- 17,481
I appear to have run into the "UK Date" problem!
I have managed to duplicate the problem, and I can recreate the problem consistently. So this indicates that it is probably a design issue.
I have attached a sample database which demonstrates a problem.
The problem is that if I use the Now() function in a normal SQL string, it returns the date correctly in UK format. However if I use the Now() function in a "built" SQL string, that is a string built out of smaller text strings, and fit the Now() function in between two text strings, I add the hash character at each end of the Now() function to indicate to MS Access that the variable is a date. This small change in the way the SQL string is assembled causes it to return the date in the U.S. format. This date is added to the table in U.S. format and completely messes up the database.
As you can see both bits of code are basically identical, except that the second example includes the hash de-limiter for the date variable. I assume this is having some effect on the date format.
Any help or advice would be greatly appreciated.
I have managed to duplicate the problem, and I can recreate the problem consistently. So this indicates that it is probably a design issue.
I have attached a sample database which demonstrates a problem.
The problem is that if I use the Now() function in a normal SQL string, it returns the date correctly in UK format. However if I use the Now() function in a "built" SQL string, that is a string built out of smaller text strings, and fit the Now() function in between two text strings, I add the hash character at each end of the Now() function to indicate to MS Access that the variable is a date. This small change in the way the SQL string is assembled causes it to return the date in the U.S. format. This date is added to the table in U.S. format and completely messes up the database.
Code:
'This works as required: (date in UK format)
strSQL = "UPDATE tblUnits SET tblUnits.UnitRepairMoveDate = Now()WHERE (((tblUnits.UnitRepairBatchNo)=44))"
Code:
'This works but : (date in US format) Not GOOD!
strSQL1 = "UPDATE tblUnits SET tblUnits.UnitRepairMoveDate = # "
strSQL2 = " #WHERE (((tblUnits.UnitRepairBatchNo)=44))"
strSQL = strSQL1 & Now() & strSQL2
As you can see both bits of code are basically identical, except that the second example includes the hash de-limiter for the date variable. I assume this is having some effect on the date format.
Any help or advice would be greatly appreciated.
Attachments
Last edited: