Solved

Day name function showing numeric values

Posted on 2013-01-26
4
264 Views
Last Modified: 2013-01-26
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.
0
Comment
Question by:UName10
  • 3
4 Comments
 
LVL 37

Accepted Solution

by:
TommySzalapski earned 500 total points
ID: 38822977
Try it like this: (Keep the day only as an integer and then convert it to a string when you create the dropdown).
I think you'll find this almost identical to what I suggested in the other question except I forgot and used 0-6 instead of 1-7.

Public Sub CreateDayNameTimeSelectionBox(strObjectName, dtCurrentDateTime, AllowNone)
    Dim iDay
    Dim iHour
    Dim iMin
    Dim i
    Dim strSelected
    if dtCurrentDateTime = "0" then
        dtCurrentDateTime = Now()
    end if
    If IsNull(dtCurrentDateTime) then
        iDay = ""
        iHour = ""
        iMin = ""
    Else
        dtCurrentDateTime = CDate(dtCurrentDateTime)
        iDay = Weekday(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="<% = WeekdayName(i) %>"<% = strSelected %>><% = WeekdayName(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

0
 

Author Comment

by:UName10
ID: 38823004
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.
0
 

Author Closing Comment

by:UName10
ID: 38823005
Perfect
0
 

Author Comment

by:UName10
ID: 38823014
It's ok - I think they need to be separate so I'll just to that...

Thanks again.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now