Hi,
having queried and tested endless options, I can't get a succesfull entry of dates in their correct format into a linked SQL Server table via Access VBA.
Situation is that I have an Access table ("AntroImport") which holds data imported from an Excel sheet. First colum holds a date/time in this format:
"8/17/2015 16:39:52"
This field "F1" itself is not formatted as a date but as text (the table is created on the fly via TransferSpreadsheet)
Via a strsql I'm trying to insert data from this table into the linked SQL Server table, in a field set as DateTime, using the following
The issue is the classical issue of MS expecting dd/mm/yyyy and reversing day and month:
"8/17/2015 16:39:52" is ok
"8/10/2015 16:39:52" results in reversed day and month value.
A classic issue, however, the classic solutions I can't get to work.
I've tried the JetDateTimeFmt constant (continueous syntax errors) and had a look at Browne's SQLdate function but in the above string I can't call this function (if I can, let me know). I've tried dozens of different Format statements.
Reason for using a sql string is that further down in the code I start using similar statements but then with dynamic table and field names, which prevent me from building Access queries.
Thanks for some advice on passing on the correct formatted date in a sql string.
having queried and tested endless options, I can't get a succesfull entry of dates in their correct format into a linked SQL Server table via Access VBA.
Situation is that I have an Access table ("AntroImport") which holds data imported from an Excel sheet. First colum holds a date/time in this format:
"8/17/2015 16:39:52"
This field "F1" itself is not formatted as a date but as text (the table is created on the fly via TransferSpreadsheet)
Via a strsql I'm trying to insert data from this table into the linked SQL Server table, in a field set as DateTime, using the following
Code:
strsqlA4 = "insert into dbo_Antropometrie (SpelerID, Datum, Lengte, Gewicht, Schoenmaat, Voetbreedte, SitReach, Zithoogte) select F2, F1, F3, Replace(F4,""."","",""), Replace(F5,""."","",""), F6, Replace(F7,""."","",""), F8 from AntroImport"
db.Execute (strsqlA4)
"8/17/2015 16:39:52" is ok
"8/10/2015 16:39:52" results in reversed day and month value.
A classic issue, however, the classic solutions I can't get to work.
I've tried the JetDateTimeFmt constant (continueous syntax errors) and had a look at Browne's SQLdate function but in the above string I can't call this function (if I can, let me know). I've tried dozens of different Format statements.
Reason for using a sql string is that further down in the code I start using similar statements but then with dynamic table and field names, which prevent me from building Access queries.
Thanks for some advice on passing on the correct formatted date in a sql string.