Extract Date from Date Time Format

pmich

Active Member
Joined
Jun 25, 2013
Messages
294
I have a monthly file with 55 Rows.
(Every month the number of rows change.)

In Col A, from Row 2 to Row 55, I have date and time as Jun 25, 2018 10:00:36 AM
I want to extract the Date from Col A to Col K from Row 2 to Row 55.

I was using =INT(A2).
Code:
Range("K2:K" & LastrecNum).Formula = "=INT(A2)"
Now it is not working in Windows 10.
(I dont know why)

I am trying to use the following code now to get my result.
Code:
   With Range("K2:K" & LastrecNum)
    .Value = DateValue(Range("A2:A" & LastrecNum).Text) 'Converts Date and Time into Number of the Date
   End With
The VBA halts in this line.
Kindly give me a suggestion.
Thanks in advance.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I can't believe it's an issue from the Windows version but just from the data !​
'Cause the formula well works only on numeric values aka real dates​
and when it not works as expected if often means the cells are not date but text …​
So easy to check it out with a workbook link on a files host website like Dropbox.​
 
Upvote 0
Thanks, Marc L, for the immediate reply.
I thought it was because I moved to Windows 10.
I am not saying it only because of W10.
How am I to check my fault.
 
Upvote 0
Thanks, Marc L, for the immediate reply.
I thought it was because I moved to Windows 10.
I am not saying that it is only because of W10.
I already received the suggestion in this forum
Converting text to date
Since there was a message that this post is old and so I posted here now.
Thanks for your suggestion to check.
How am I to check my fault?
Please guide me.
Though I have given my replies to a few of the questions raised in this forum, I a, not an expert.
Hence, need your guidance.
Thanks in advance.
 
Upvote 0
=LEFT(A2,12) works. But the result is, Jun 25, 2018.
I want it to be 25-Jun-2018.
Please suggest.
 
Upvote 0
In A2 I have Jun 25, 2018
I used =LEFT(A2,12) in J2.
I got Jun 25, 2018.
I did format J2 as [DATE] and chose [14-Mar-2001] [Eng (US)] and nothing changed.
But I tried using =LEFT(A2,12) in VBA Code.
I replaced
Code:
Range("K2:K" & LastrecNum).Formula = "=INT(A2)"
Range("K2:K" & LastrecNum).NumberFormat = "dd-mmm-yyyy"
with
Code:
Range("K2:K" & LastrecNum).Formula = "=LEFT(A2,12)"
Range("K2:K" & LastrecNum).NumberFormat = "dd-mmm-yyyy"
I got 25-Jun-2018.
Thanks for the support in this forum.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,951
Messages
6,122,449
Members
449,083
Latest member
Ava19

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