PC Review


Reply
Thread Tools Rate Thread

Cut time from string ?

 
 
Emory Richter
Guest
Posts: n/a
 
      22nd Apr 2007

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
 
Reply With Quote
 
 
 
 
JE McGimpsey
Guest
Posts: n/a
 
      22nd Apr 2007
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 <(E-Mail Removed)>,
Emory Richter <(E-Mail Removed)> 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

 
Reply With Quote
 
merjet
Guest
Posts: n/a
 
      22nd Apr 2007
ActiveCell = DateValue(ActiveCell)

Hth,
Merjet


 
Reply With Quote
 
Emory Richter
Guest
Posts: n/a
 
      23rd Apr 2007
Hi jemcgimpsey

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

Emory

In article <jemcgimpsey-(E-Mail Removed)>,
(E-Mail Removed) 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 <(E-Mail Removed)>,
> Emory Richter <(E-Mail Removed)> 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

>

 
Reply With Quote
 
Emory Richter
Guest
Posts: n/a
 
      23rd Apr 2007
In article <(E-Mail Removed)>,
(E-Mail Removed) says...
> Merjet
>


Merjet
Thank you for your answer.
Emory
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Going through a string, a char at a time. NateBuckley Microsoft Excel Programming 5 30th May 2008 08:38 PM
String to Time =?Utf-8?B?d2lsbGlhbXI=?= Microsoft Access Form Coding 10 24th Mar 2007 03:31 PM
Function to convert Time String to Time Andibevan Microsoft Excel Worksheet Functions 6 19th Aug 2005 01:19 PM
Converting from string to time and subtracting two time fields Anamik Microsoft Access Queries 1 27th Oct 2004 02:01 PM
Concatenate Time in String DD Microsoft Access Reports 4 22nd Apr 2004 12:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:12 AM.