Marko Stojovic
Registered User.
- Local time
- Today, 08:50
- Joined
- Jan 25, 2001
- Messages
- 29
Hi there!
Every time I think I've understood how to handle dates in VBA programmes, it gets back at me big time.
This time, I have a select query which picks up a certain date (select top 1 event_date from x where person_ref=y). This query is in a loop, so the date differs each time the query is run, depending on the y-criterion.
I have actually embedded this select query into an INSERT statement, like this:
currentdb.execute "INSERT into Z values (person_ref,#" & currentdb.createquerydef("","SELECT...").openrecordset.fields(0) & "#))
What happens is that some dates are reproduced in the Z table accurately, but others, like for instance August 2nd, are inserted as 8th of February. Next, I tried to enclose the entire section from the second "currentdb" to the "fields(0)" bit with DATEVALUE() - same result. After this, I tried to include DATEVALUE() in the SELECT statement itself ("select top 1 datevalue(event_date)"...) - same result. Then I tried both, again same result!
My question is, what does one have to do to select a date from one table and successfully insert it into another table?!?
(By the way, I'm in the UK, hence the whole confusion. I realise the query could be done more efficiently with parameters etc, but it will only be run once and that doesn't really matter!)
Thanks in advance!
Marko
[This message has been edited by Marko Stojovic (edited 04-10-2002).]
Every time I think I've understood how to handle dates in VBA programmes, it gets back at me big time.
This time, I have a select query which picks up a certain date (select top 1 event_date from x where person_ref=y). This query is in a loop, so the date differs each time the query is run, depending on the y-criterion.
I have actually embedded this select query into an INSERT statement, like this:
currentdb.execute "INSERT into Z values (person_ref,#" & currentdb.createquerydef("","SELECT...").openrecordset.fields(0) & "#))
What happens is that some dates are reproduced in the Z table accurately, but others, like for instance August 2nd, are inserted as 8th of February. Next, I tried to enclose the entire section from the second "currentdb" to the "fields(0)" bit with DATEVALUE() - same result. After this, I tried to include DATEVALUE() in the SELECT statement itself ("select top 1 datevalue(event_date)"...) - same result. Then I tried both, again same result!
My question is, what does one have to do to select a date from one table and successfully insert it into another table?!?
(By the way, I'm in the UK, hence the whole confusion. I realise the query could be done more efficiently with parameters etc, but it will only be run once and that doesn't really matter!)
Thanks in advance!
Marko
[This message has been edited by Marko Stojovic (edited 04-10-2002).]