How can I get the format dd:mm:yy hh:nn AMPM from dd:mm:yy hh:nn:ss AMPM?

Posted on 2006-04-03
Last Modified: 2011-09-20
Hi Experts,

How can I get the format dd:mm:yy hh:nn AMPM  from dd:mm:yy hh:nn:ss AMPM?

Basically I want the seconds to drop out.

Question by:indyng
    LVL 8

    Accepted Solution


    <% timestring = "04/04/06 04:14:03 AM" %>

    <%  Private Function FormatTimeNoSeconds(strTime)
        On Error Resume Next

        'Store the Time
        Dim DT
        DT = TimeValue(strTime)
        DD = datevalue(strTime)

        'Strip out the seconds
        Dim TimePart
        TimePart = Left(DT, Len(DT) - 6)

        'Get the AM/PM designation
        Dim AMPMPart
        AMPMPart = Right(DT, 3)

        'Rebuild the string
        FormatTimeNoSeconds = DD & " " & TimePart & AMPMPart
    End Function


    Should return 04/04/06 4:14 AM

    LVL 6

    Expert Comment

    Dim Time
    Dim TimePart
    Dim TimeSplit

    Time = FormatDateTime(Now(), 3)

    TimePart = split(Time," ")
    TimeSplit = split(TimePart(0),":")

    Response.write date() & " " & TimeSplit(0) & ":" & TimeSplit(1) & " " & TimePart(1)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
    Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video discusses moving either the default database or any database to a new volume.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now