Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time format from Access Database

Status
Not open for further replies.
Joined
Jul 14, 2003
Messages
116
Location
CA
Hello,

I'm trying to display the value from a time field but I'm having trouble with the format. The format I have in the access database is Medium time. (e.g. 12:00 PM) However when I display the time on an ASP page it comes out in Long time. (e.g. 12:00:00 PM) I am trying to figure how to get the medium format with ASP. Can I format the value with and ASP function?
 
I am using the FormatDateTime function trying to use both Long Date and Long Time. My only problem is the long time. I can not get the Long Time to display the AM/PM. How can I do this.

This is my exact code.

<CODE>
<SCRIPT Language=vbscript>
Sub Gettime()
Dim DiffDays, DiffHrs, DiffMin, DiffSec, dTime
dTime = document.clock.dDate.value & " " & document.clock.dTime.value
xmts.innerText = " " & dTime & " "
DiffSec = DateDiff("s",dTime, Now)

mts.innerText = " " & DiffSec & " "
DiffDays = Fix(DiffSec/86400)
DiffSec = DiffSec - DiffDays * 86400
DiffHrs = Fix(DiffSec/3600)
DiffSec = DiffSec - DiffHrs * 3600
DiffMin = Fix(DiffSec/60)
DiffSec = DiffSec - DiffMin * 60
document.clock.dDiff.value = DiffDays & " days " & DiffHrs & ":" & DiffMin & ":" & Diffsec
end Sub
</SCRIPT>
<BODY onLoad="startclock()">
<form name="clock" onSubmit="0">
<%
sql = "SELECT DraftNumber,Team_ID, OnDeck,DraftTime from tblCurrentDrafter ORDER BY DraftNumber DESC"
set rs = conn.execute(sql)
if not rs.eof then
Draftdate = formatdateTime(rs("DraftTime"),2)
Drafttime = formatdateTime(rs("DraftTime"),3)
End If
set rs = nothing

%>
<TABLE>
<TR>
<TD colspan=2><Div id="xmts">hello</Div></TD>
</TR>
<TR>
<TD colspan=2><Div id="mts">hello</Div></TD>
</TR>

</CODE>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top