Solved

Day name function showing numeric values

Posted on 2013-01-26
4
260 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

708 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

19 Experts available now in Live!

Get 1:1 Help Now