Re: Design Month "2" into "02" by christina
christina
Fri Feb 23 08:31:13 CST 2007
On 23 Feb., 14:36, "ekkehard.horner" <ekkehard.hor...@arcor.de> wrote:
> christina.t...@gmx.de wrote:
> > Hi,
> > I have a problem with my VBS. I want to replace an old date with the
> > currently date in a special file. The Replace-Funktion works but the
> > replaced month is "2". I want to replace it with "02". Do you have any
> > Idea how this could work?
>
> > Heute = Date
> > contents=replace(contents, a, Year(Heute) & "-" & Month(Heute) & "-" &
> > Day(Heute)")
>
> > The result should be: 2007-02-23
> > Kind regards
> > Tina
>
> Dim dtHeute : dtHeute = Date
> Dim sHeute : sHeute = Year( dtHeute ) & "-" _
> & Right( "0" & Month( dtHeute ), 2 ) & "-" _
> & Right( 100 + Day( dtHeute ), 2 )
> Dim sA : sA = "01.01.1970"
> Dim sContents : sContents = "abcd" + sA + "ef"
> WScript.Echo sContents
> sContents = Replace( sContents, sA, sHeute )
> WScript.Echo sContents
>
> The second method to prepend a "0" conditionally is (c) M. Harris.
> Output:
>
> abcd01.01.1970ef
> abcd2007-02-23ef
It works! Thank you so much!