ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cut time from string ? (https://www.excelbanter.com/excel-programming/387926-cut-time-string.html)

Emory Richter[_3_]

Cut time from string ?
 

I have a date/time in the form of:

12/24/2006 4:21:49 AM

I want only 12/24/2006.

How do I get rid of 4:21:49 AM ?


Formating *shows* only 12/24/2006
but the time is still part of the data.

If I try:

ActiveCell.Formula = Left(ActiveCell.Formula, 10)
or
ActiveCell.Formula = Mid(ActiveCell.Formula, 1, 10)

the string is not shortened
but the number of seconds seems to diminish.

Thank you,
Emory

JE McGimpsey

Cut time from string ?
 
XL stores date/times as integer and fractional offsets from a base date.


Try entering this in the immediate window:

?CDbl(Date), CDbl(Time), CDbl(Now)

So

ActiveCell.Value = Int(ActiveCell.Value)

will get rid of the time portion.


In article ,
Emory Richter wrote:

I have a date/time in the form of:

12/24/2006 4:21:49 AM

I want only 12/24/2006.

How do I get rid of 4:21:49 AM ?


Formating *shows* only 12/24/2006
but the time is still part of the data.

If I try:

ActiveCell.Formula = Left(ActiveCell.Formula, 10)
or
ActiveCell.Formula = Mid(ActiveCell.Formula, 1, 10)

the string is not shortened
but the number of seconds seems to diminish.

Thank you,
Emory


merjet

Cut time from string ?
 
ActiveCell = DateValue(ActiveCell)

Hth,
Merjet



Emory Richter

Cut time from string ?
 
Hi jemcgimpsey

Thank you for the explaination
and the code
which works fine.

Emory

In article ,
says...
XL stores date/times as integer and fractional offsets from a base date.


Try entering this in the immediate window:

?CDbl(Date), CDbl(Time), CDbl(Now)

So

ActiveCell.Value = Int(ActiveCell.Value)

will get rid of the time portion.


In article ,
Emory Richter wrote:

I have a date/time in the form of:

12/24/2006 4:21:49 AM

I want only 12/24/2006.

How do I get rid of 4:21:49 AM ?


Formating *shows* only 12/24/2006
but the time is still part of the data.

If I try:

ActiveCell.Formula = Left(ActiveCell.Formula, 10)
or
ActiveCell.Formula = Mid(ActiveCell.Formula, 1, 10)

the string is not shortened
but the number of seconds seems to diminish.

Thank you,
Emory



Emory Richter

Cut time from string ?
 
In article . com,
says...
Merjet


Merjet
Thank you for your answer.
Emory


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com