iCurrent to Double Digits

Discussion in 'ASP General' started by msnews.microsoft.com, Aug 24, 2004.

  1. Hey Guys,

    I was wondering if any of you could help me out with converting a single
    digit (ie: 1, 2, 3, etc) to double digits (ie: 01, 02, 03, etc).

    I am trying to convert the date in DD/MM/YYYY format so it is always
    displayed as 01/01/2004 instead of 1/1/2004.

    The script I am trying to embed this into has similar attributes to the
    Calendar on this site located at http://www.asp101.com/samples/calendar.asp
    and the objects that require to be double digits are iCurrent and
    Month(dDate).

    Thanks Heaps!!!
    msnews.microsoft.com, Aug 24, 2004
    #1
    1. Advertising

  2. msnews.microsoft.com

    Evertjan. Guest

    msnews.microsoft.com wrote on 24 aug 2004 in
    microsoft.public.inetserver.asp.general:

    > I was wondering if any of you could help me out with converting a
    > single digit (ie: 1, 2, 3, etc) to double digits (ie: 01, 02, 03,
    > etc).
    >
    > I am trying to convert the date in DD/MM/YYYY format so it is always
    > displayed as 01/01/2004 instead of 1/1/2004.
    >
    > The script I am trying to embed this into has similar attributes to
    > the Calendar on this site located at
    > http://www.asp101.com/samples/calendar.asp and the objects that
    > require to be double digits are iCurrent and Month(dDate).
    >


    There are many ways to Rome, as the ancient said.
    I presume you want vbscript.

    <script type="text/vbscript">

    Set Response = document '' IE as test environment

    function two(x) '' expecting x<=0
    two = "" & x
    if x<10 then two = "0" & two
    end function

    function convert(x) '' x=(d)d/(m)m/yyyy [or (m)m/(d)d/yyyy]
    a = split(x,"/")
    a(0) = two(a(0))
    a(1) = two(a(1))
    convert = join(a,"/")
    end function

    Response.write convert("1/1/2004")

    </script>


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Aug 24, 2004
    #2
    1. Advertising

  3. msnews.microsoft.com

    PJ Laurenson Guest

    Ok, cool.
    So how do I apply that and let it work in the function as follows:

    If iCurrent = Day(dDate) Then
    Response.Write vbTab & vbTab & "<td background=""mv_today.gif""><b>" &
    iCurrent & "</b></td>" & vbCrLf
    Else
    Response.Write vbTab & vbTab & "<td><a href=""./calendar.asp?date=" &
    iCurrent & "/" & Month(dDate) & "/" & Year(dDate) & """>" & iCurrent &
    "</a></td>" & vbCrLf
    End If

    Thanks,

    PJ

    "Evertjan." <> wrote in message
    news:Xns954F5FC21448Beejj99@194.109.133.29...
    > msnews.microsoft.com wrote on 24 aug 2004 in
    > microsoft.public.inetserver.asp.general:
    >
    > > I was wondering if any of you could help me out with converting a
    > > single digit (ie: 1, 2, 3, etc) to double digits (ie: 01, 02, 03,
    > > etc).
    > >
    > > I am trying to convert the date in DD/MM/YYYY format so it is always
    > > displayed as 01/01/2004 instead of 1/1/2004.
    > >
    > > The script I am trying to embed this into has similar attributes to
    > > the Calendar on this site located at
    > > http://www.asp101.com/samples/calendar.asp and the objects that
    > > require to be double digits are iCurrent and Month(dDate).
    > >

    >
    > There are many ways to Rome, as the ancient said.
    > I presume you want vbscript.
    >
    > <script type="text/vbscript">
    >
    > Set Response = document '' IE as test environment
    >
    > function two(x) '' expecting x<=0
    > two = "" & x
    > if x<10 then two = "0" & two
    > end function
    >
    > function convert(x) '' x=(d)d/(m)m/yyyy [or (m)m/(d)d/yyyy]
    > a = split(x,"/")
    > a(0) = two(a(0))
    > a(1) = two(a(1))
    > convert = join(a,"/")
    > end function
    >
    > Response.write convert("1/1/2004")
    >
    > </script>
    >
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
    PJ Laurenson, Aug 24, 2004
    #3
  4. msnews.microsoft.com

    Evertjan. Guest

    PJ Laurenson wrote on 24 aug 2004 in
    microsoft.public.inetserver.asp.general:
    > "Evertjan." <> wrote in message

    [...]
    >> <script type="text/vbscript">
    >>
    >> Set Response = document '' IE as test environment
    >>
    >> function two(x) '' expecting x<=0
    >> two = "" & x
    >> if x<10 then two = "0" & two
    >> end function
    >>
    >> function convert(x) '' x=(d)d/(m)m/yyyy [or (m)m/(d)d/yyyy]
    >> a = split(x,"/")
    >> a(0) = two(a(0))
    >> a(1) = two(a(1))
    >> convert = join(a,"/")
    >> end function
    >>
    >> Response.write convert("1/1/2004")
    >>
    >> </script>


    [please do not toppost on usenet]

    > Ok, cool.
    > So how do I apply that and let it work in the function as follows:
    >
    > If iCurrent = Day(dDate) Then
    > Response.Write vbTab & vbTab & "<td background=""mv_today.gif""><b>" &
    > iCurrent & "</b></td>" & vbCrLf
    > Else
    > Response.Write vbTab & vbTab & "<td><a href=""./calendar.asp?date=" &
    > iCurrent & "/" & Month(dDate) & "/" & Year(dDate) & """>" & iCurrent &
    > "</a></td>" & vbCrLf
    > End If


    you would need only the Two() function:

    .... & two(iCurrent) & "/" & two(Month(dDate)) & ....

    btw: PJ, if you had analyzed my code for yourself, you could have found
    that out without asking. This is not a criticism, but an inducement to
    analyze. And analyze you must, if you are using otherman's code.

    ====================

    some hints:

    But why changing the date format in this page as you could do it after
    submission in calendar.asp?

    Why the ./ which does not add a thing?

    Why send the date down to and up from the client and not keep it in a
    session variable serverside?

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Aug 24, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Web learner

    from List <double> to double[]

    Web learner, Apr 25, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    461
  2. Sydex
    Replies:
    12
    Views:
    6,442
    Victor Bazarov
    Feb 17, 2005
  3. mrstephengross

    How to detect a double's significant digits

    mrstephengross, May 5, 2005, in forum: Python
    Replies:
    29
    Views:
    812
    AnswerGuy
    May 23, 2005
  4. Jonny
    Replies:
    6
    Views:
    327
    Walter Bright
    Oct 10, 2005
  5. PJ Laurenson

    iCurrent to Double Digits

    PJ Laurenson, Aug 24, 2004, in forum: ASP General
    Replies:
    0
    Views:
    96
    PJ Laurenson
    Aug 24, 2004
Loading...

Share This Page