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
How can I get the format dd/mm/yy hh:mm AM/PM from Now() ?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
acperkins,
I am a little confused. How does this function output a result?
Thanks
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()
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()
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
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")
</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
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
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