Re: Date format problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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

.



Relevant Pages

  • Re: Formatting output
    ... I am trying to do formatted output of single digit decimals. ... //and my attempt to format the output ... You write a string; the third parameter is optional and is the number of bytes to write. ... You need fprintf() instead. ...
    (alt.php)
  • Re: Formatting output
    ... I am trying to do formatted output of single digit decimals. ... //and my attempt to format the output ... You write a string; the third parameter is optional and is the number of bytes to write. ... You need fprintf() instead. ...
    (alt.php)
  • Re: Date format problem
    ... My problem is the date format can change i.t may look like this in different ... >> i have a variable which consist of datetime in string format ... >> dim str as String ... > single digit months and/or days), then Michael's method is the way you ...
    (microsoft.public.vb.general.discussion)
  • RE: Date format problem
    ... in case this format is constant, you can extract the date from teh string ... the date should always be 10 chars. ... > dim str as String ...
    (microsoft.public.vb.general.discussion)
  • Re: date question
    ... I have a string in the format ... Have to to take the date and lpad it with ZERO if its a single digit. ...
    (comp.databases.oracle.misc)