From: joseph Frank on
I have a column of dates with the following format

'9/23/2006 0:00:00'

I would like to delete the 0:00:00 part is their a way to delete them so I would be left with 9/23/2006 only
From: Matt J on
"joseph Frank" <josephfrank1969(a)hotmail.com> wrote in message <hi6tr3$j2f$1(a)fred.mathworks.com>...
> I have a column of dates with the following format
>
> '9/23/2006 0:00:00'
>
> I would like to delete the 0:00:00 part is their a way to delete them so I would be left with 9/23/2006 only

>> strrep('9/23/2006 0:00:00', ' 0:00:00' , '')

ans =

9/23/2006
From: Oleg Komarov on
"joseph Frank"
> I have a column of dates with the following format
>
> '9/23/2006 0:00:00'
>
> I would like to delete the 0:00:00 part is their a way to delete them so I would be left with 9/23/2006 only
One of the solutions...

SampleVec:{
'9/23/2006 0:00:00'
'10/23/2006 0:00:00'
}
datestr(SampleVec,'mm/dd/yyyy')

ans =
09/23/2006
10/23/2006

Oleg
From: us on
"Oleg Komarov" <oleg.komarov(a)hotmail.it> wrote in message <hi6udr$rn5$1(a)fred.mathworks.com>...
> "joseph Frank"
> > I have a column of dates with the following format
> >
> > '9/23/2006 0:00:00'
> >
> > I would like to delete the 0:00:00 part is their a way to delete them so I would be left with 9/23/2006 only
> One of the solutions...
>
> SampleVec:{

a great solution - provided the OP corrects the minute typo...

SampleVec={
% ...

:-)
us
From: Oleg Komarov on
"us "
> "Oleg Komarov"
> > "joseph Frank"
> > > I have a column of dates with the following format
> > >
> > > '9/23/2006 0:00:00'
> > >
> > > I would like to delete the 0:00:00 part is their a way to delete them so I would be left with 9/23/2006 only
> > One of the solutions...
> >
> > SampleVec:{
>
> a great solution - provided the OP corrects the minute typo...
>
> SampleVec={
> % ...
>
> :-)
> us

Sure us,
SampleVec = repmat({
'9/23/2006 0:00:00'
'10/23/2006 0:00:00'
},100,1);

tic;A = strrep(SampleVec, ' 0:00:00' , '');toc;
tic;B = cellstr(datestr(SampleVec,'mm/dd/yyyy'));toc;

Elapsed time is 0.000263 seconds.
Elapsed time is 0.055394 seconds.
My solution (B) is slower and gives a slightly different ans (it adds 0 to days < 10).

Oleg
 |  Next  |  Last
Pages: 1 2
Prev: bitwise operation in simulink.
Next: affinity matrix