Link to home
Start Free TrialLog in
Avatar of UName10
UName10Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Day name function showing numeric values

I've got the function with the day name, hour and minute in one, but the day name is a numeric value.

I'm currently getting 1-7 for the day name, 00-23 for hours and 00-29 for minutes.

I need to have the day name as Monday etc (not numeric).

This is the function:

Public Sub CreateDayNameTimeSelectionBox(strObjectName, dtCurrentDateTime, AllowNone)
    Dim idayName
    Dim iHour
    Dim iMin
    Dim i
    Dim strSelected
    if dtCurrentDateTime = "0" then
        dtCurrentDateTime = Now()
    end if
    If IsNull(dtCurrentDateTime) then
        idayName = ""
        iHour = ""
        iMin = ""
    Else
        dtCurrentDateTime = CDate(dtCurrentDateTime)
        idayName = WeekdayName(dtCurrentDateTime)
        iHour = Hour(dtCurrentDateTime)
        iMin = Minute(dtCurrentDateTime)
    End If
    %>
	<select name="<% = strObjectName %>_dayName" ID="Select1" class="input-list">
		<%
		If AllowNone = True then
		    %><option value=""> - </option><%
		end if
		For i = 1 to 7
			if i = idayName then
				strSelected = " SELECTED "
			else
				strSelected = ""
			end if
			%><option value="<% = i %>"<% = strSelected %>><% = i %></option><%
		Next
		%>
	</select>
    <select name="<% = strObjectName %>_Hour" class="input-list">
        <%
        If AllowNone = True then
            %><option value=""> - </option><%
        End if
        For i = 0 to 23
            if i = iHour then
                strSelected = " SELECTED "
            Else
                strSelected = ""
            end if
            %><option value="<% = Right("00" & Trim(CStr(i)), 2) %>" <% = strSelected %>><% = Right("00" & Trim(CStr(i)), 2) %></option><%
        Next
        %>
    </select>
    <select name="<% = strObjectName %>_Min" class="input-list">
        <%
        If AllowNone = True then
            %><option value=""> - </option><%
        End if
        For i = 0 to 59
            if i = iMin then
                strSelected = " SELECTED "
            Else
                strSelected = ""
            end if
            %><option value="<% = Right("00" & Trim(CStr(i)), 2) %>" <% = strSelected %>><% = Right("00" & Trim(CStr(i)), 2) %></option><%
        Next
        %>
    </select>
    <%
End Sub

Open in new window


And here's where I call it in:

<% CreateDayNameTimeSelectionBox "OpenHours", NULL, False %>

Open in new window


Any help much appreciated.
ASKER CERTIFIED SOLUTION
Avatar of TommySzalapski
TommySzalapski
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 UName10

ASKER

Brilliant - you're a star, thank you.

Do you know how I can get all day selects listed in one line instead of creating seven separate drop downs?

E.g.

          <th align="left" valign="top">
          	<% CreateDayNameTimeSelectionBox "OpenHours", NULL, False %>
          </th>

Open in new window


Many thanks for the help and I'll accept the solution now.
Avatar of UName10

ASKER

Perfect
Avatar of UName10

ASKER

It's ok - I think they need to be separate so I'll just to that...

Thanks again.