Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Remove time from date

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Remove time from date

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.

"Little Penny" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Remove time from date

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".

--
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility
Free and Pro versions

"Little Penny" wrote in message
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Remove time from date

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


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
remove the date, leave the time Matrix Excel Discussion (Misc queries) 7 May 1st 10 07:04 PM
Remove Time from Date Rob Excel Discussion (Misc queries) 3 March 5th 08 06:33 PM
Remove Time Element of a Date jennie Excel Worksheet Functions 3 July 8th 05 11:36 AM
Remove time from a date and time field? Format removes the displa. oaoboc Excel Worksheet Functions 1 February 16th 05 07:20 PM
Remove time from date time Prem Chandiramani Excel Programming 1 September 17th 03 11:10 AM


All times are GMT +1. The time now is 10:05 PM.

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

About Us

"It's about Microsoft Excel"