Link to home
Start Free TrialLog in
Avatar of indyng
indyng

asked on

How can I get the format dd/mm/yy hh:mm AM/PM ?

Hi Experts,

How can I get the format dd/mm/yy hh:mm AM/PM  from Now() ?

Thanks
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

You can
1. Hope the Regional Settings are set correctly on the server and use something like this: FormatDateTime(Now(), vbGeneralDate)
2. Write a function to output in the format you need.
3. Use ASP.NET
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of indyng
indyng

ASKER

acperkins,

I am a little confused.  How does this function output a result?

Thanks
>>How does this function output a result?<<
How you want to use the function depends entirely on you.  For example, to display the value you could use something like this:

Response.Write GetCurrentDate()
Avatar of indyng

ASKER

acperkins,

Sorry I am not very good at asp yet.

How can I pass a value to the function?

I have

        <td width="13%" align="center">
          <FONT><%=rs("ETADateTime")%></FONT>
        </td>

i want to use GetCurrentDate() on rs("ETADateTime")

Thanks
Change it as follows:

Function GetDate(ByVal Dat)
Dim AMPM

If Hour(Dat) < 12 Then
     AMPM = " AM"
Else
     AMPM = " PM"
End If

GetDate = LPad(Day(Dat)) & "/" & LPad(Month(Dat)) & "/" & CStr(Year(Dat)) & " " & _
                    LPad((Hour(Dat) - 1) Mod 12 + 1) & ":" & LPad(Minute(Dat)) & AMPM

End Function

Function LPad(ByVal Value)

LPad = Right("0" & CStr(Value), 2)

End Function