Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default VBA / SQL: problem with dates

Hey guys,

I'm trying to update some data in an Access DB from Excel using ADO & SQL.
I'd like to update some fields with a defined criteria using the WHERE clause
in SQL, but dates seem not to work...

I use the SQL string like:

UPDATE [table] SET [field1] = 'aa', [field2] = #15/01/2005# etc... _
WHERE [field3] = 'bla' AND [field4] = #01/01/2005#

I believe that the problem is the date I'm filtering... I copied the whole
SQL string into access and did not work. But if I remove the date criteria
seems to work.

I appreciate your help.
Thanks & Bregards

Santiago
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default VBA / SQL: problem with dates

Try wrapping the date in the FORMAT function so, instead of #15/01/2005#,
you have FORMAT(#15/01/2005#,"dd-mmm-yyyy").

It just might be that VBA or SQL (or both) are trying to recognise an
American date format rather than the English format.

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Santiago" wrote in message
...
Hey guys,

I'm trying to update some data in an Access DB from Excel using ADO & SQL.
I'd like to update some fields with a defined criteria using the WHERE

clause
in SQL, but dates seem not to work...

I use the SQL string like:

UPDATE [table] SET [field1] = 'aa', [field2] = #15/01/2005# etc... _
WHERE [field3] = 'bla' AND [field4] = #01/01/2005#

I believe that the problem is the date I'm filtering... I copied the whole
SQL string into access and did not work. But if I remove the date criteria
seems to work.

I appreciate your help.
Thanks & Bregards

Santiago



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA / SQL: problem with dates

Have you tried an unambiguous date string like "15-Jan-2005"?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andy Wiggins" wrote in message
...
Try wrapping the date in the FORMAT function so, instead of #15/01/2005#,
you have FORMAT(#15/01/2005#,"dd-mmm-yyyy").

It just might be that VBA or SQL (or both) are trying to recognise an
American date format rather than the English format.

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Santiago" wrote in message
...
Hey guys,

I'm trying to update some data in an Access DB from Excel using ADO &

SQL.
I'd like to update some fields with a defined criteria using the WHERE

clause
in SQL, but dates seem not to work...

I use the SQL string like:

UPDATE [table] SET [field1] = 'aa', [field2] = #15/01/2005# etc... _
WHERE [field3] = 'bla' AND [field4] = #01/01/2005#

I believe that the problem is the date I'm filtering... I copied the

whole
SQL string into access and did not work. But if I remove the date

criteria
seems to work.

I appreciate your help.
Thanks & Bregards

Santiago





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default VBA / SQL: problem with dates

My code usually collects a date from somewhere, assigns it to a variable and
then passes it on to something like the OP's query. I was interpretting the
example in those terms and not assuming the OP was actually using a
hard-coded date :-)

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Bob Phillips" wrote in message
...
Have you tried an unambiguous date string like "15-Jan-2005"?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andy Wiggins" wrote in message
...
Try wrapping the date in the FORMAT function so, instead of

#15/01/2005#,
you have FORMAT(#15/01/2005#,"dd-mmm-yyyy").

It just might be that VBA or SQL (or both) are trying to recognise an
American date format rather than the English format.

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Santiago" wrote in message
...
Hey guys,

I'm trying to update some data in an Access DB from Excel using ADO &

SQL.
I'd like to update some fields with a defined criteria using the WHERE

clause
in SQL, but dates seem not to work...

I use the SQL string like:

UPDATE [table] SET [field1] = 'aa', [field2] = #15/01/2005# etc... _
WHERE [field3] = 'bla' AND [field4] = #01/01/2005#

I believe that the problem is the date I'm filtering... I copied the

whole
SQL string into access and did not work. But if I remove the date

criteria
seems to work.

I appreciate your help.
Thanks & Bregards

Santiago







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default VBA / SQL: problem with dates

Even collected it can be formatted thus.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andy Wiggins" wrote in message
...
My code usually collects a date from somewhere, assigns it to a variable

and
then passes it on to something like the OP's query. I was interpretting

the
example in those terms and not assuming the OP was actually using a
hard-coded date :-)

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Bob Phillips" wrote in message
...
Have you tried an unambiguous date string like "15-Jan-2005"?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andy Wiggins" wrote in message
...
Try wrapping the date in the FORMAT function so, instead of

#15/01/2005#,
you have FORMAT(#15/01/2005#,"dd-mmm-yyyy").

It just might be that VBA or SQL (or both) are trying to recognise an
American date format rather than the English format.

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Santiago" wrote in message
...
Hey guys,

I'm trying to update some data in an Access DB from Excel using ADO

&
SQL.
I'd like to update some fields with a defined criteria using the

WHERE
clause
in SQL, but dates seem not to work...

I use the SQL string like:

UPDATE [table] SET [field1] = 'aa', [field2] = #15/01/2005# etc... _
WHERE [field3] = 'bla' AND [field4] = #01/01/2005#

I believe that the problem is the date I'm filtering... I copied the

whole
SQL string into access and did not work. But if I remove the date

criteria
seems to work.

I appreciate your help.
Thanks & Bregards

Santiago










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default VBA / SQL: problem with dates

I'll take your word for it, but my experience tells me to use format.

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Bob Phillips" wrote in message
...
Even collected it can be formatted thus.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andy Wiggins" wrote in message
...
My code usually collects a date from somewhere, assigns it to a variable

and
then passes it on to something like the OP's query. I was interpretting

the
example in those terms and not assuming the OP was actually using a
hard-coded date :-)

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Bob Phillips" wrote in message
...
Have you tried an unambiguous date string like "15-Jan-2005"?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andy Wiggins" wrote in message
...
Try wrapping the date in the FORMAT function so, instead of

#15/01/2005#,
you have FORMAT(#15/01/2005#,"dd-mmm-yyyy").

It just might be that VBA or SQL (or both) are trying to recognise

an
American date format rather than the English format.

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Santiago" wrote in message
...
Hey guys,

I'm trying to update some data in an Access DB from Excel using

ADO
&
SQL.
I'd like to update some fields with a defined criteria using the

WHERE
clause
in SQL, but dates seem not to work...

I use the SQL string like:

UPDATE [table] SET [field1] = 'aa', [field2] = #15/01/2005# etc...

_
WHERE [field3] = 'bla' AND [field4] = #01/01/2005#

I believe that the problem is the date I'm filtering... I copied

the
whole
SQL string into access and did not work. But if I remove the date
criteria
seems to work.

I appreciate your help.
Thanks & Bregards

Santiago










  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default VBA / SQL: problem with dates

I've tried both: with the format() function and also with unambiguous
dates... doesn't work...

It's quite annoying I must say... you work out your code and doesn't work
because of these format matters... :-(

"Bob Phillips" wrote:

Have you tried an unambiguous date string like "15-Jan-2005"?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andy Wiggins" wrote in message
...
Try wrapping the date in the FORMAT function so, instead of #15/01/2005#,
you have FORMAT(#15/01/2005#,"dd-mmm-yyyy").

It just might be that VBA or SQL (or both) are trying to recognise an
American date format rather than the English format.

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Santiago" wrote in message
...
Hey guys,

I'm trying to update some data in an Access DB from Excel using ADO &

SQL.
I'd like to update some fields with a defined criteria using the WHERE

clause
in SQL, but dates seem not to work...

I use the SQL string like:

UPDATE [table] SET [field1] = 'aa', [field2] = #15/01/2005# etc... _
WHERE [field3] = 'bla' AND [field4] = #01/01/2005#

I believe that the problem is the date I'm filtering... I copied the

whole
SQL string into access and did not work. But if I remove the date

criteria
seems to work.

I appreciate your help.
Thanks & Bregards

Santiago






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default VBA / SQL: problem with dates

:-(

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Santiago" wrote in message
...
I've tried both: with the format() function and also with unambiguous
dates... doesn't work...

It's quite annoying I must say... you work out your code and doesn't work
because of these format matters... :-(

"Bob Phillips" wrote:

Have you tried an unambiguous date string like "15-Jan-2005"?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andy Wiggins" wrote in message
...
Try wrapping the date in the FORMAT function so, instead of

#15/01/2005#,
you have FORMAT(#15/01/2005#,"dd-mmm-yyyy").

It just might be that VBA or SQL (or both) are trying to recognise an
American date format rather than the English format.

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Santiago" wrote in message
...
Hey guys,

I'm trying to update some data in an Access DB from Excel using ADO

&
SQL.
I'd like to update some fields with a defined criteria using the

WHERE
clause
in SQL, but dates seem not to work...

I use the SQL string like:

UPDATE [table] SET [field1] = 'aa', [field2] = #15/01/2005# etc... _
WHERE [field3] = 'bla' AND [field4] = #01/01/2005#

I believe that the problem is the date I'm filtering... I copied the

whole
SQL string into access and did not work. But if I remove the date

criteria
seems to work.

I appreciate your help.
Thanks & Bregards

Santiago







  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default VBA / SQL: problem with dates

I'll try assigning the contents of the cell previously to a Date variable,
but I'm not positive towards this... It's really ****ing me off!

"Andy Wiggins" wrote:

:-(

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Santiago" wrote in message
...
I've tried both: with the format() function and also with unambiguous
dates... doesn't work...

It's quite annoying I must say... you work out your code and doesn't work
because of these format matters... :-(

"Bob Phillips" wrote:

Have you tried an unambiguous date string like "15-Jan-2005"?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andy Wiggins" wrote in message
...
Try wrapping the date in the FORMAT function so, instead of

#15/01/2005#,
you have FORMAT(#15/01/2005#,"dd-mmm-yyyy").

It just might be that VBA or SQL (or both) are trying to recognise an
American date format rather than the English format.

--
Andy Wiggins FCCA
www.BygSoftware.com
Excel, Access and VBA Consultancy
-

"Santiago" wrote in message
...
Hey guys,

I'm trying to update some data in an Access DB from Excel using ADO

&
SQL.
I'd like to update some fields with a defined criteria using the

WHERE
clause
in SQL, but dates seem not to work...

I use the SQL string like:

UPDATE [table] SET [field1] = 'aa', [field2] = #15/01/2005# etc... _
WHERE [field3] = 'bla' AND [field4] = #01/01/2005#

I believe that the problem is the date I'm filtering... I copied the
whole
SQL string into access and did not work. But if I remove the date
criteria
seems to work.

I appreciate your help.
Thanks & Bregards

Santiago








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dates problem Andrew Mackenzie Excel Discussion (Misc queries) 2 December 29th 08 04:06 PM
Problem with dates Stuart Perry Excel Discussion (Misc queries) 3 January 7th 08 10:06 AM
Problem with dates Carpe Diem Excel Worksheet Functions 2 September 11th 07 12:21 PM
Dates Problem nicole0904 Excel Discussion (Misc queries) 5 May 10th 06 02:47 PM
Problem with dates Emece Excel Worksheet Functions 7 December 22nd 04 06:47 PM


All times are GMT +1. The time now is 05:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"