Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How to split the date without "/" in asp?

    Dear,

    How to split the date "1/8/2004" in to 01082004?

    If posible make it in the single line?
    eg: < % Split(strDate, "/") ... ???

    PS: i want to add the 0 ,if there are 1 digit of value. -- this is the problem i face on.
    Last edited by NinjaTurtle; 08-06-2004 at 05:04 AM.
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I already solve the problem. TQ
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++

  • #3
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    Well, glad I could help.

    Now there is a little issue of my fee?

    $10,000 in small, unmarked bills.
    Thank you.

  • #4
    New Coder
    Join Date
    Oct 2003
    Location
    19° 26' N, 99° 7' W
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How did you solved it, we might find a similar situation some time...

  • #5
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    After I looked at this post, I tried to do it. I tried to use programed in functions, and the best I could do is:
    Code:
    <%
    Response.Write Day(Date) & Month(Date) & Year(Date)
    %>
    This doesn't solve the problem, so I thought making a function would help.

    This would work, but is more than one line, so it's what I was hoping:
    Code:
    <%
    Function LeadingZero(strVar)
      If Len(strVar) = 1 Then
        LeadingZero = "0" & strVar
      Else
          LeadingZero = strVar
      End If
    End Function
    
    Response.Write LeadingZero(Day(Date)) & LeadingZero(Month(Date)) & Year(Date)
    %>
    I looked up the format function, but I couldn't find the type of function I was looking for. I want to use something like DateFunction(Date(), "ddmmyyyy").
    Key:
    d - day.
    dd - day with leading zero if applicable.
    m - month.
    mm - month with leading zero if applicable.
    yyyy - year.
    yy - last two digits of the year.

    Also with time.
    s - seconds.
    ss - seconds with leading zero if applicable.
    n - minute
    nn - minute with leading zero if applicable.
    h - hour
    hh - hour with leading zero if applicable.
    hhh - hour in military time

    And of course any added characters would not be effected, so adding a slash would still be there.

    But I can't find a function like this already built into asp.

    I know there is function in vb that already has keys and already adds a leading zero:
    Code:
    MsgBox Format(Date, "ddmmyyyy")
    I want to find/make the Format function in vb and add it to my webserver, or my included function.asp page.



    Edit:
    I found this link, which gives me a dll I can register onto my server so it will be allow me to use the format function from vb in ASP.

    I also found this link, which shows you the keys for the format function. Something I was looking for already built into ASP.
    http://www.apostate.com/programming/vb-format.html
    http://www.4guysfromrolla.com/webtech/051601-1.shtml

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Posts
    358
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Dear,

    Actually my solution is what Morgoth mentioned!!! )
    Thanks.
    =====================================================
    From NinjaTurtle
    ++http://ohmygoh.blogspot.com|http://technology.ohmygoh.com++

  • #7
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    And for a possible non-DLL-required way to go:

    To make a variable be in the format of mm/dd/yyyy (and the final line of code can be modifed for other date formats), perhaps try something like the following which you might even make into a function:

    varFld = CDate(MyVariable)

    intMonth = Month(varFld)
    intDay = Day(varFld)
    intYr = Year(varFld)

    If intMonth < 10 Then
    strMonth = "0" & CStr(intMonth)
    Else
    strMonth = CStr(intMonth)
    End If

    If intDay < 10 Then
    strDay = "0" & CStr(intDay)
    Else
    strDay = CStr(intDay)
    End If

    strYr = Right(CStr(intYr), 4) ' And change the 4 to 2 for 2 year dates.

    varFld = CStr(strMonth & "/" & strDay & "/" & strYr)
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •