Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Trying to use serialdate in database array

Sorry for my dyslexia, I mean dateserial, which is what I have in my code.

Joel,

I still get a this error:

Run-time error '1004':
SQL Syntax Error

Any ideas?
"joel" wrote in message
...
MyDate = serialdate(year(now)-1, month(now), day(now))

"SELECT `Combined Data`.`Assignee Mgr Name`, `Combined Data`.`SR
Reported Date`" & Chr(13) & "" & Chr(10) & "FROM `Combined Data` `Combined
Data`" & Chr(13) & "" & Chr(10) & "WHERE (`Combined Data`.`Assignee Mgr
Name`='SMITH, GEORGE') AND (`Combi" _
, _
"ned Data`.`SR Reported Date`={ts '" & MyDate & "'})" &
Chr(13) &
"" & Chr(10) & "ORDER BY `Combined Data`.`SR Reported Date`" _
)



"Brian" wrote:

Howdy all,

I have this line in a macro:

..CommandText = Array( _
"SELECT `Combined Data`.`Assignee Mgr Name`, `Combined Data`.`SR
Reported Date`" & Chr(13) & "" & Chr(10) & "FROM `Combined Data`
`Combined
Data`" & Chr(13) & "" & Chr(10) & "WHERE (`Combined Data`.`Assignee Mgr
Name`='SMITH, GEORGE') AND (`Combi" _
, _
"ned Data`.`SR Reported Date`={ts '2008-01-01 00:00:01'})" &
Chr(13) &
"" & Chr(10) & "ORDER BY `Combined Data`.`SR Reported Date`" _
)

What I want to change is the date ('2008-01-01 00:00:01') to something
like
this:

serialdate(year(now)-1, month(now), day(now))

In order to have the results return be from today's date to one year
previous.
When I substitute my line in the code, I get a 1004 error at this line:

..Refresh BackgroundQuery:=False

Any ideas?

Thanks,
Brian








  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Trying to use serialdate in database array

I think it is looking for text with a "-" between the year-month-day

MyDate = DateSerial(Year(Now) - 1, Month(Now), Day(Now))
MyDate = Format(MyDate, "YYYY-MM-DD HH:MM:SS")


"Brian" wrote:

Sorry for my dyslexia, I mean dateserial, which is what I have in my code.

Joel,

I still get a this error:

Run-time error '1004':
SQL Syntax Error

Any ideas?
"joel" wrote in message
...
MyDate = serialdate(year(now)-1, month(now), day(now))

"SELECT `Combined Data`.`Assignee Mgr Name`, `Combined Data`.`SR
Reported Date`" & Chr(13) & "" & Chr(10) & "FROM `Combined Data` `Combined
Data`" & Chr(13) & "" & Chr(10) & "WHERE (`Combined Data`.`Assignee Mgr
Name`='SMITH, GEORGE') AND (`Combi" _
, _
"ned Data`.`SR Reported Date`={ts '" & MyDate & "'})" &
Chr(13) &
"" & Chr(10) & "ORDER BY `Combined Data`.`SR Reported Date`" _
)



"Brian" wrote:

Howdy all,

I have this line in a macro:

..CommandText = Array( _
"SELECT `Combined Data`.`Assignee Mgr Name`, `Combined Data`.`SR
Reported Date`" & Chr(13) & "" & Chr(10) & "FROM `Combined Data`
`Combined
Data`" & Chr(13) & "" & Chr(10) & "WHERE (`Combined Data`.`Assignee Mgr
Name`='SMITH, GEORGE') AND (`Combi" _
, _
"ned Data`.`SR Reported Date`={ts '2008-01-01 00:00:01'})" &
Chr(13) &
"" & Chr(10) & "ORDER BY `Combined Data`.`SR Reported Date`" _
)

What I want to change is the date ('2008-01-01 00:00:01') to something
like
this:

serialdate(year(now)-1, month(now), day(now))

In order to have the results return be from today's date to one year
previous.
When I substitute my line in the code, I get a 1004 error at this line:

..Refresh BackgroundQuery:=False

Any ideas?

Thanks,
Brian









  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Trying to use serialdate in database array

Thanks Joel, you were correct.

Works like a charm.

Brian
"joel" wrote in message
...
I think it is looking for text with a "-" between the year-month-day

MyDate = DateSerial(Year(Now) - 1, Month(Now), Day(Now))
MyDate = Format(MyDate, "YYYY-MM-DD HH:MM:SS")


"Brian" wrote:

Sorry for my dyslexia, I mean dateserial, which is what I have in my
code.

Joel,

I still get a this error:

Run-time error '1004':
SQL Syntax Error

Any ideas?
"joel" wrote in message
...
MyDate = serialdate(year(now)-1, month(now), day(now))

"SELECT `Combined Data`.`Assignee Mgr Name`, `Combined Data`.`SR
Reported Date`" & Chr(13) & "" & Chr(10) & "FROM `Combined Data`
`Combined
Data`" & Chr(13) & "" & Chr(10) & "WHERE (`Combined Data`.`Assignee Mgr
Name`='SMITH, GEORGE') AND (`Combi" _
, _
"ned Data`.`SR Reported Date`={ts '" & MyDate & "'})" &
Chr(13) &
"" & Chr(10) & "ORDER BY `Combined Data`.`SR Reported Date`" _
)



"Brian" wrote:

Howdy all,

I have this line in a macro:

..CommandText = Array( _
"SELECT `Combined Data`.`Assignee Mgr Name`, `Combined
Data`.`SR
Reported Date`" & Chr(13) & "" & Chr(10) & "FROM `Combined Data`
`Combined
Data`" & Chr(13) & "" & Chr(10) & "WHERE (`Combined Data`.`Assignee
Mgr
Name`='SMITH, GEORGE') AND (`Combi" _
, _
"ned Data`.`SR Reported Date`={ts '2008-01-01 00:00:01'})" &
Chr(13) &
"" & Chr(10) & "ORDER BY `Combined Data`.`SR Reported Date`" _
)

What I want to change is the date ('2008-01-01 00:00:01') to something
like
this:

serialdate(year(now)-1, month(now), day(now))

In order to have the results return be from today's date to one year
previous.
When I substitute my line in the code, I get a 1004 error at this
line:

..Refresh BackgroundQuery:=False

Any ideas?

Thanks,
Brian











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
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R[_2_] Excel Programming 3 November 13th 07 04:08 PM
HELP: VBA Code to extract data from an SQL Server database and put it into Access Database Clinton M James[_2_] Excel Programming 1 October 8th 07 12:44 AM
database query not showing foxpro database How I import data mangat New Users to Excel 1 June 24th 07 03:31 PM
efficiency: database functions vs. math functions vs. array formula nickname Excel Discussion (Misc queries) 2 July 14th 06 04:26 AM
Using Excel as a database and need macro or vba to take data entered on one tab and update the database by adding to the next avail row rjr Excel Programming 5 June 11th 06 09:43 PM


All times are GMT +1. The time now is 03:49 PM.

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

About Us

"It's about Microsoft Excel"