Re: Date format problem
- From: "Rick Rothstein" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Wed, 4 May 2005 08:21:22 -0400
> > > this might be a simple question
> > > i have a variable which consist of datetime in string
> > > format for example
> > > dim str as String
> > > str = 2004-10-25-11.39.16
> > >
> > > i need to clilp the time from the str and return only
> > > the date . in my case it sould be 2004-10-25 . Is
> > > there a function for this if the return date is in string
> > > then it would be much easier for me
> >
> > If the month and day fields are always 2-digits (leading
> > zeroes on single digit months and/or days), then Michael's
> > method is the way you should go. On the other hand, if
> > this is not the case, try this...
> >
> > DatePortion = Left$(DateString, InStrRev(DateString, "-") - 1)
> >
> My problem is the date format can change i.t may look like
> this in different setting.
> so how to get only the date without time
I have a feeling, based on your answer so far, that the date format your
program has to deal can vary. If that is the case, then there probably
will be no "simple" answer to your question; rather, we will have to
craft one for you. Howerver, it is a little hard to give you a
comprehensive answer to your question if we don't know the ways in which
the date string might vary. Could you take a sample date and list for us
the different ways it might be "shaped" for your program to deal with?
That way, we won't have to guess at what your program has to deal with.
Also, make sure the sample date uses a single digit month and day so we
can see if has leading zeroes or not.
Rick - MVP
.
- References:
- Date format problem
- From: Prashantha Weerakoon
- Re: Date format problem
- From: Rick Rothstein
- Re: Date format problem
- From: Prashantha Weerakoon
- Date format problem
- Prev by Date: Re: Late Binding in Word
- Next by Date: UNICODE CONVERTS TO ASCII
- Previous by thread: Re: Date format problem
- Next by thread: Re: Date format problem
- Index(es):
Relevant Pages
|