Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Entering Date via SQL Query

My underlying database is Excel and I am writing all DB relate
operations using ADO in Visual Basic Editor of Excel (VBA). I am usin
Excel Driver. The data is stored directly into Excel columns a
mentioned in the insert query.

But, when I enter the date value in a column, it attaches
single-quote(') before the value. I have applied date-formatting to th
respective column as (mm/dd/yyyy), but still it doesn't work. I want t
programmatically enter the date value without any single-quote i.e th
value should be treated as date datatype.

Because of this single-quote(') to the date value which the date-valu
in the cell to be considered as TEXT and hence whenever I want to fetc
records between date-range, the SELECT query does not pick-up prope
records.

[Since the end-user of my application will not open the files and mak
manual changes, i want the proper date entry to be made without an
single quote...]

Sample Query:
INSERT INTO [mms_instrDR_dtl$](strInstrSeqNbr, dtDR
dtCreated,strCreatedBy
VALUES('CLDEL01040400002',#7/21/2004#,#7/21/2004#,'ajit')

Please help me !!! Trying from last 2 days.

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Entering Date via SQL Query

Have you tried using a string in the SQL Insert statement?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ajitrajput " wrote in message
...
My underlying database is Excel and I am writing all DB related
operations using ADO in Visual Basic Editor of Excel (VBA). I am using
Excel Driver. The data is stored directly into Excel columns as
mentioned in the insert query.

But, when I enter the date value in a column, it attaches a
single-quote(') before the value. I have applied date-formatting to the
respective column as (mm/dd/yyyy), but still it doesn't work. I want to
programmatically enter the date value without any single-quote i.e the
value should be treated as date datatype.

Because of this single-quote(') to the date value which the date-value
in the cell to be considered as TEXT and hence whenever I want to fetch
records between date-range, the SELECT query does not pick-up proper
records.

[Since the end-user of my application will not open the files and make
manual changes, i want the proper date entry to be made without any
single quote...]

Sample Query:
INSERT INTO [mms_instrDR_dtl$](strInstrSeqNbr, dtDR,
dtCreated,strCreatedBy)
VALUES('CLDEL01040400002',#7/21/2004#,#7/21/2004#,'ajit')

Please help me !!! Trying from last 2 days..


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default Entering Date via SQL Query

ajitrajput wrote ...

My underlying database is Excel and I am writing all DB related
operations using ADO in Visual Basic Editor of Excel (VBA). I am using
Excel Driver. The data is stored directly into Excel columns as
mentioned in the insert query.

But, when I enter the date value in a column, it attaches a
single-quote(') before the value. I have applied date-formatting to the
respective column as (mm/dd/yyyy), but still it doesn't work. I want to
programmatically enter the date value without any single-quote i.e the
value should be treated as date datatype.

Because of this single-quote(') to the date value which the date-value
in the cell to be considered as TEXT and hence whenever I want to fetch
records between date-range, the SELECT query does not pick-up proper
records.

[Since the end-user of my application will not open the files and make
manual changes, i want the proper date entry to be made without any
single quote...]

Sample Query:
INSERT INTO [mms_instrDR_dtl$](strInstrSeqNbr, dtDR,
dtCreated,strCreatedBy)
VALUES('CLDEL01040400002',#7/21/2004#,#7/21/2004#,'ajit')


You need to get an appreciation of how Jet determines the data type of
an Excel column i.e. it is not just determined by formatting but also
by existing values in the column and machine-specific settings. This
may help:

http://www.dicks-blog.com/excel/2004...al_data_m.html

Once Jet has determined that the majority type for the column is
'Date' (adDBTimeStamp) then it should be able to coerce an unambiguous
date string e.g.

INSERT INTO
[mms_instrDR_dtl$]
(strInstrSeqNbr, dtDR, dtCreated,strCreatedBy)
VALUES ('CLDEL01040400002', '21 JUL 2004', '21 JUL 2004', 'ajit')
;

Having said all that, I can't seem to get it to work with the ODBC
Excel driver via the OLE DB provider for ODBC; I get an error,
'Operation must use an updatable query'. With ADO, I usually use the
Microsoft OLE DB Provider for Jet and the insert works fine with this.

Out of interest, why you are using the ODBC dirver and not the OLE DB
Provider for Jet?

Jamie.

--
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Entering Date via SQL Query

Jamie Collins wrote:
*ajitrajput wrote ...

My underlying database is Excel and I am writing all DB related
operations using ADO in Visual Basic Editor of Excel (VBA). I a

using
Excel Driver. The data is stored directly into Excel columns as
mentioned in the insert query.

But, when I enter the date value in a column, it attaches a
single-quote(') before the value. I have applied date-formatting t

the
respective column as (mm/dd/yyyy), but still it doesn't work.

want to
programmatically enter the date value without any single-quote i.

the
value should be treated as date datatype.

Because of this single-quote(') to the date value which th

date-value
in the cell to be considered as TEXT and hence whenever I want t

fetch
records between date-range, the SELECT query does not pick-u

proper
records.

[Since the end-user of my application will not open the files an

make
manual changes, i want the proper date entry to be made withou

any
single quote...]

Sample Query:
INSERT INTO [mms_instrDR_dtl$](strInstrSeqNbr, dtDR,
dtCreated,strCreatedBy)
VALUES('CLDEL01040400002',#7/21/2004#,#7/21/2004#,'ajit')


You need to get an appreciation of how Jet determines the data typ
of
an Excel column i.e. it is not just determined by formatting bu
also
by existing values in the column and machine-specific settings. This
may help:

http://www.dicks-blog.com/excel/2004...al_data_m.html

Once Jet has determined that the majority type for the column is
'Date' (adDBTimeStamp) then it should be able to coerce a
unambiguous
date string e.g.

INSERT INTO
[mms_instrDR_dtl$]
(strInstrSeqNbr, dtDR, dtCreated,strCreatedBy)
VALUES ('CLDEL01040400002', '21 JUL 2004', '21 JUL 2004', 'ajit')
;

Having said all that, I can't seem to get it to work with the ODBC
Excel driver via the OLE DB provider for ODBC; I get an error,
'Operation must use an updatable query'. With ADO, I usually us
the
Microsoft OLE DB Provider for Jet and the insert works fine wit
this.

Out of interest, why you are using the ODBC dirver and not the OL
DB
Provider for Jet?

Jamie.

-- *



Can you please pass on the code/connection-string where you have use
OLE DB Driver. It's giving an error to me. :(

Thanks in advance.....

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Entering Date via SQL Query

What does yours look like? Anything like this?

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\mySpreadsheet.xls;" & _
"Extended Properties=""Excel 8.0;HDR=Yes"""

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ajitrajput " wrote in message
...
Jamie Collins wrote:
*ajitrajput wrote ...

My underlying database is Excel and I am writing all DB related
operations using ADO in Visual Basic Editor of Excel (VBA). I am

using
Excel Driver. The data is stored directly into Excel columns as
mentioned in the insert query.

But, when I enter the date value in a column, it attaches a
single-quote(') before the value. I have applied date-formatting to

the
respective column as (mm/dd/yyyy), but still it doesn't work. I

want to
programmatically enter the date value without any single-quote i.e

the
value should be treated as date datatype.

Because of this single-quote(') to the date value which the

date-value
in the cell to be considered as TEXT and hence whenever I want to

fetch
records between date-range, the SELECT query does not pick-up

proper
records.

[Since the end-user of my application will not open the files and

make
manual changes, i want the proper date entry to be made without

any
single quote...]

Sample Query:
INSERT INTO [mms_instrDR_dtl$](strInstrSeqNbr, dtDR,
dtCreated,strCreatedBy)
VALUES('CLDEL01040400002',#7/21/2004#,#7/21/2004#,'ajit')


You need to get an appreciation of how Jet determines the data type
of
an Excel column i.e. it is not just determined by formatting but
also
by existing values in the column and machine-specific settings. This
may help:

http://www.dicks-blog.com/excel/2004...al_data_m.html

Once Jet has determined that the majority type for the column is
'Date' (adDBTimeStamp) then it should be able to coerce an
unambiguous
date string e.g.

INSERT INTO
[mms_instrDR_dtl$]
(strInstrSeqNbr, dtDR, dtCreated,strCreatedBy)
VALUES ('CLDEL01040400002', '21 JUL 2004', '21 JUL 2004', 'ajit')
;

Having said all that, I can't seem to get it to work with the ODBC
Excel driver via the OLE DB provider for ODBC; I get an error,
'Operation must use an updatable query'. With ADO, I usually use
the
Microsoft OLE DB Provider for Jet and the insert works fine with
this.

Out of interest, why you are using the ODBC dirver and not the OLE
DB
Provider for Jet?

Jamie.

-- *



Can you please pass on the code/connection-string where you have used
OLE DB Driver. It's giving an error to me. :(

Thanks in advance......


---
Message posted from http://www.ExcelForum.com/



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
entering parameter criteria MS Query KM01 Excel Discussion (Misc queries) 0 April 29th 10 12:46 PM
Microsoft Query - Entering Column Names with Blanks Robert Meade Excel Discussion (Misc queries) 0 December 6th 07 01:19 AM
Automatically entering date David F Cox Excel Discussion (Misc queries) 0 October 11th 06 09:52 PM
In Excel 2003, entering date without slashes, the date is incorre. sj Excel Discussion (Misc queries) 6 January 6th 05 03:07 PM
Entering Query Parameters by UserForm David Excel Programming 2 April 29th 04 09:21 AM


All times are GMT +1. The time now is 11:41 AM.

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"