Forums
This topic is locked
Sorting AM/PM
Posted 27 May 2002 06:54:36
1
has voted
27 May 2002 06:54:36 David Hayes posted:
I'm creating a schedule page that displays all of the current days times. I have it so that it sorts the list by the Start_time Column in the SQL statement, it works great until I mix in both AM and PM recordsHere is the current syntax that each Start_Time is stored in:
HH:MM:SS AP
Any Ideas on how I could sort the Start_time by AM/PM?
Thanks,
fliquid
Replies
Replied 27 May 2002 08:21:13
27 May 2002 08:21:13 Matthijs Horsman replied:
Replied 27 May 2002 18:43:37
27 May 2002 18:43:37 David Hayes replied:
I use ASP(VBscript) with an access database. Sorry I should of mentioned this before. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Replied 27 May 2002 19:32:48
27 May 2002 19:32:48 David Behan replied:
I had a tricky client that was very particular about their dates. They wanted them in 24 hour clock and AM/PM format. I didn't know of an automatic script that did this so here is what I did:
<b>I used the Ultradev dodatetime function:</b>
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
function DoDateTime(str, nNamedFormat, nLCID)
dim strRet
dim nOldLCID
strRet = str
If (nLCID > -1) Then
oldLCID = Session.LCID
End If
On Error Resume Next
If (nLCID > -1) Then
Session.LCID = nLCID
End If
If ((nLCID < 0) Or (Session.LCID = nLCID)) Then
strRet = FormatDateTime(str, nNamedFormat)
End If
If (nLCID > -1) Then
Session.LCID = oldLCID
End If
DoDateTime = strRet
End Function
</SCRIPT>
<b>AND this for the display of the time format they wanted:</b>
<%= DoDateTime((rsInfo.Fields.Item("ts_departure"
.Value), 4, 1033) %>
<% IF (rsInfo.Fields.Item("ts_departure"
.Value) < #12:00# THEN Response.Write " AM" ELSE Response.Write " PM" END IF %>
Try something like that and see...
Regards
Dave
_________________________
David Behan - www.site-manager.com/af.asp?a=11&l=1tds9p6x2
<b>I used the Ultradev dodatetime function:</b>
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
function DoDateTime(str, nNamedFormat, nLCID)
dim strRet
dim nOldLCID
strRet = str
If (nLCID > -1) Then
oldLCID = Session.LCID
End If
On Error Resume Next
If (nLCID > -1) Then
Session.LCID = nLCID
End If
If ((nLCID < 0) Or (Session.LCID = nLCID)) Then
strRet = FormatDateTime(str, nNamedFormat)
End If
If (nLCID > -1) Then
Session.LCID = oldLCID
End If
DoDateTime = strRet
End Function
</SCRIPT>
<b>AND this for the display of the time format they wanted:</b>
<%= DoDateTime((rsInfo.Fields.Item("ts_departure"

<% IF (rsInfo.Fields.Item("ts_departure"

Try something like that and see...
Regards
Dave
_________________________
David Behan - www.site-manager.com/af.asp?a=11&l=1tds9p6x2