Remove time from date

L

Little Penny

Is there a macro that can remove the time from the date. I tried
formating the cell and it remove time from the cell. However if you
select the cell the time remains.

3/20/2009 8:10:40 PM
 
J

Joel

You just need the mod function to get the fractional part of the time. Use
this

=Mod(A1,1)

Format the results in any time format you choose.
 
T

Tim Zych

If you mean you removed the time portion and it still displayed 12:00:00 AM,
that is correct...the date/time at 0 hours, 0 minutes, 0 seconds into the
day is exactly midnight.

DateValue will strip off the time or, to put it another way, convert the
time to exactly midnight.

Dim dt As Date
dt = Now()
MsgBox DateValue(dt)

Use a function to get the date-only portion of a date(time). Use formatting
to display the results without the time, e.g. "m/d/yy".
 
J

Jacob Skaria

The below code will extract the date part from Column A and write to Column
B. Please try...

If this post helps click Yes
--------------
Jacob Skaria


Dim intRow
intRow = 1
Do While Range("A" & intRow) <> ""
Range("B" & intRow) = Format(Range("A" & intRow), "dd-mm-yyyy")
intRow = intRow + 1
Loop
 
Top