Access to Excel Date issue

stapuff

Well-known Member
Joined
Feb 19, 2004
Messages
1,126
When I am bring data into Excel from Access - the dates are getting converted from mm/dd/yyyy to the general format (39564). How can I change this back to a date? Can it be done in the SQL statement? The selecting of a column and formatting it will not work for my app. Columns do not line up.


Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=N:\opr\database.mdb"
MySQLcheck = "SELECT [WAREHOUSE],[PARTNUMBER],[ORDER_NUM],[TRANS_DESC],[QUANTITY],[AVAIL_QTY],[ENTER_DATE],[TRANS_DATE] from CUS_REQ"
Set rst = cnn.Execute(MySQLcheck)
FieldCount = (rst.Fields.Count)
rst.MoveFirst
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
39564 is a date...

Format the Destination Cells as Date instead of General or Number...

Hope this helps.
 
Upvote 0
How?


The data is getting dumped into Excel via CopyRecordSet from Access. Do you have an example?
 
Upvote 0
Yer kill'in me.

I have about a thousand different ranges to go through. I need this via VBA since the columns do not line up to make this simple.
 
Upvote 0
Well, basic code would be something like this...

Range("A1:A100").NumberFormat = "mm/dd/yyyy"

I'm sure something could be written up, but need to know HOW the could would know which columns to format as a date?
Do you have Header Names or something ?
 
Upvote 0
The yer kill'in me was me laughing BTW.

I was thinking about a Find Loop looking for word "DATE", selecting offset(1,0), Range(Selection, Selection.End(xlDown)).Select, Selection.NumberFormat = "m/d/yyyy"

Your thoughts
 
Upvote 0
The yer kill'in me was me laughing BTW.

I was thinking about a Find Loop looking for word "DATE", selecting offset(1,0), Range(Selection, Selection.End(xlDown)).Select, Selection.NumberFormat = "m/d/yyyy"

Your thoughts

I know...lol..
Yes that would work, but you dont' have to loop...

Assuming headers in row 1

x = Application.Match("DATE",Rows(1),0)
Range(Cells(2,x),Cells(Rows.Count,x).End(xlup)).NumberFormat = "m/d/yyyy"

Also, Nate's Idea is probably better. Should get it right at the source...
 
Upvote 0
Nate:

Back to the old pic?

I tried CDate([ENTER_DATE]) - the only thing I see that changed was the heading.
Went from ENTER_DATE to Expr1006?


Expr1006 this was ENTER_DATE
39429
39429
39429
39429
39429
39429
39500
39519
39519
 
Upvote 0

Forum statistics

Threads
1,223,247
Messages
6,171,004
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top