Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Date Code Problem

0 views
Skip to first unread message

Steve

unread,
Apr 20, 2002, 10:18:31 AM4/20/02
to
Hi,

I am trying to develop some code that basically limits which days of the
current week you can view in a list/menu based on the current day. So if I
it Tuesday I'll only see Tuesday,Monday,Sunday dates...

I cannot get the dates to display on the asp page...and would also like to
have the date formatted in the vbLongDate but I am not sure where to insert
the code for that.

I have pasted the code in below and any help would be appreciated

Thanks

Steve

<------Code------>

<select size="1" name="StevesDate" style="font-size: 8pt">
<%
x = 0 'initialize the variable
do while not datePart("w", now()- x) = 7 ' set up the loop and tell the
loop when to stop
%>
<option <%=datePart("w", now()- x)%> value="1"><%=(date()- x)%></option>
<%
x = x + 1
if x > 8 then exit do 'oops. Something is wrong so make sure we exit
loop

%>
</select>


Deepa Jacob

unread,
Apr 20, 2002, 2:29:29 PM4/20/02
to
Sub fromSunday()
Dim dDate, weekd, i, curDate
dDate = date
weekd = weekday(dDate)
%>

<select size="1" name="StevesDate" style="font-size: 8pt">
<%
for i = weekd to 1 step -1
curDate = dDate - weekd + i
%>
<option <%=curDate%> value="1"><%=FormatDateTime(curDate,
1)%></option>
<%
'''''second argument given to FormatDateTime is vbLongDate=1
next
%>
</select>
<%
End Sub

This is a sample, if u intended to show just the days in the current week
from sunday to the current day.

-Deepa


"Steve" <Ste...@popmail.com> wrote in message
news:ugi38bH6BHA.1204@tkmsftngp05...

Steve

unread,
Apr 20, 2002, 4:04:31 PM4/20/02
to
Deepa,

I inserted your code into my page...but still cannot get anything to
display...I have pasted the whole page here could you take a look at if for
me and see where I am going wrong. The date format I am looking for is
Saturday April 20, 2002

Thanks

Steve

<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/NetSys.asp" -->
<%
Dim rs1__username
rs1__username = "%"
if (Session("MM_username") <> "") then rs1__username =
Session("MM_username")
%>
<%
set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.ActiveConnection = MM_NetSys_STRING
rs1.Source = "SELECT DISTINCT User FROM weblogin WHERE CompanyEmailName =
'" + Replace(rs1__username, "'", "''") + "' ORDER BY User"
rs1.CursorType = 0
rs1.CursorLocation = 2
rs1.LockType = 3
rs1.Open()
rs1_numRows = 0
%>
<%
Dim rs2__var_jobnum
rs2__var_jobnum = "%"
if (request.querystring("var_jobnum") <> "") then rs2__var_jobnum =
request.querystring("var_jobnum")
%>
<%
set rs2 = Server.CreateObject("ADODB.Recordset")
rs2.ActiveConnection = MM_NetSys_STRING
rs2.Source = "SELECT * FROM timejobselection WHERE JobComplete = 0 AND
JobNumber = '" + Replace(rs2__var_jobnum, "'", "''") + "' ORDER BY
JobNumber, CompanyName"
rs2.CursorType = 0
rs2.CursorLocation = 2
rs2.LockType = 3
rs2.Open()
rs2_numRows = 0
%>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="/css/InfoDeli.css" type="text/css">
<script language="JavaScript">
function doClock(){ // By Paul Davis - www.kaosweaver.com
var t=new Date(),a=doClock.arguments,str="",i,a1,lang="1";
var month=new Array('January','Jan', 'February','Feb', 'March','Mar',
'April','Apr', 'May','May', 'June','Jun', 'July','Jul', 'August','Aug',
'September','Sep', 'October','Oct', 'November','Nov', 'December','Dec');
var tday= new Array('Sunday','Sun','Monday','Mon', 'Tuesday','Tue',
'Wednesday','Wed','Thursday','Thr','Friday','Fri','Saturday','Sat');
for(i=0;i<a.length;i++) {a1=a[i].charAt(1);switch (a[i].charAt(0)) {
case "M":if ((Number(a1)==3) && ((t.getMonth()+1)<10)) str+="0";
str+=(Number(a1)>1)?t.getMonth()+1:month[t.getMonth()*2+Number(a1)];break;
case "D": if ((Number(a1)==1) && (t.getDate()<10))
str+="0";str+=t.getDate();break;
case "Y":
str+=(a1=='0')?t.getFullYear():t.getFullYear().toString().substring(2);break
;
case "W":str+=tday[t.getDay()*2+Number(a1)];break; default:
str+=unescape(a[i]);}}return str;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000"><table width="100%" border="0"
cellspacing="0" cellpadding="1">
<tr>
<td> <table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td width="1%">&nbsp;</td>
<td colspan="3" bgcolor="#6699FF" align="center" valign="middle"
class="RegCopyBold">Time
Entry Form</td>
<td width="1%">&nbsp;</td>
</tr>
<tr>
<td width="1%">&nbsp;</td>
<td colspan="2" class="RegCopy">&nbsp; </td>
<td width="33%">&nbsp;</td>
<td width="1%">&nbsp;</td>
</tr>
<tr>
<td width="1%">&nbsp;</td>
<td colspan="3"> <form name="form2" method="post" action=""> <table
width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td class="RegCopy" width="14%" height="28">Employee</td>
<td class="RegCopy" width="74%"
height="28"><%=(rs1.Fields.Item("User").Value)%></td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
</tr>
<tr>
<td class="RegCopy" width="14%" height="28">Job Number</td>
<td class="RegCopy" width="74%"
height="28"><%=(rs2.Fields.Item("JobNumber").Value)%></td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
</tr>
<tr>
<td class="RegCopy" width="14%" height="28">Select Date
</td>
<td class="headingblue" width="74%" height="28">


<select size="1" name="StevesDate" style="font-size:

8pt" class="headingblue">


<%
for i = weekd to 1 step -1
curDate = dDate - weekd + i
%>
<option <%=curDate%>

value="1"><%=FormatDateTime(curDate,1)%></option>


<%
'''''second argument given to FormatDateTime is vbLongDate=1
next
%>
</select>
<%

Sub fromSunday()
Dim dDate, weekd, i, curDate
dDate = date
weekd = weekday(dDate)

End Sub
%>
</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
</tr>
<tr>
<td class="RegCopy" width="14%" height="28">Enter
Time</td>
<td class="RegCopy" width="74%" height="28"> Hours
<select name="hours">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
</select>
&nbsp; Minutes&nbsp;
<select name="minutes">
<option value="00" selected>00</option>
<option value="15">15</option>
<option value="30">30</option>
<option value="45">45</option>
</select>
</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
</tr>
<tr align="left" valign="top">
<td class="RegCopy" width="14%" height="28">Notes</td>
<td class="RegCopy" width="74%" height="28">
<textarea name="notes" cols="75"></textarea>
</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
</tr>
<tr>
<td class="RegCopy" width="14%" height="28">&nbsp;</td>
<td class="RegCopy" width="74%" height="28">
<input type="submit" name="Enter" value="Enter">
&nbsp;&nbsp;
<input type="reset" name="Reset" value="Reset">
</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
<td class="RegCopy" width="4%" height="28">&nbsp;</td>
</tr>
<tr>
<td class="RegCopy" width="14%" height="24">&nbsp;</td>
<td class="RegCopy" width="74%" height="24">&nbsp; </td>
<td class="RegCopy" width="4%">&nbsp;</td>
<td class="RegCopy" width="4%">&nbsp;</td>
<td class="RegCopy" width="4%">&nbsp;</td>
</tr>
</table>
</form>
</td>
<td width="1%">&nbsp;</td>
</tr>
<tr>
<td width="1%">&nbsp;</td>
<td width="22%" class="RegCopy">&nbsp;</td>
<td width="43%" class="RegCopy">&nbsp;</td>
<td width="33%" class="RegCopy">&nbsp;</td>
<td width="1%">&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<%
rs1.Close()
%>
<%
rs2.Close()
%>

"Deepa Jacob" <deepa_k...@hotmail.com> wrote in message
news:uhrk3kJ6BHA.2116@tkmsftngp02...

Deepa Jacob

unread,
Apr 20, 2002, 4:40:42 PM4/20/02
to
i didn't go thru th whole code, i went thru just the part of that date
function

Replace
the following part of the code

with
------------------------------------------------------------------

------------------------------------------------------------------


------------------------------------------------------------


<td class="headingblue" width="74%" height="28">
<select size="1" name="StevesDate" style="font-size:
8pt" class="headingblue">
<%
for i = weekd to 1 step -1
curDate = dDate - weekd + i
%>
<option <%=curDate%>
value="1"><%=FormatDateTime(curDate,1)%></option>
<%
'''''second argument given to FormatDateTime is vbLongDate=1
next
%>
</select>
<%
Sub fromSunday()
Dim dDate, weekd, i, curDate
dDate = date
weekd = weekday(dDate)
End Sub
%>
</td>

-------------------------------------------------------------


"Steve" <Ste...@popmail.com> wrote in message

news:O8#4HdK6BHA.2332@tkmsftngp05...

Deepa Jacob

unread,
Apr 20, 2002, 4:42:15 PM4/20/02
to
sorry i just sent a mistake post, i hadn't completed typing and did ctrl s,
i'll send the full code just now
-Deepa

"Steve" <Ste...@popmail.com> wrote in message

news:O8#4HdK6BHA.2332@tkmsftngp05...

Deepa Jacob

unread,
Apr 20, 2002, 4:45:07 PM4/20/02
to
U didn't insert the function properly.
 
 
replace with the following part
---------------------------------------------------------------------------------
<td class="headingblue" width="74%" height="28">
                    <select size="1" name="StevesDate" style="font-size:
8pt" class="headingblue">
                      <%
       Dim dDate, weekd, i, curDate
     dDate = date
     weekd = weekday(dDate)
     for i = weekd to 1 step -1
          curDate = dDate - weekd + i
          %>
              <option <%=curDate%> value="1"><%=FormatDateTime(curDate,1)%></option>
              <%
          '''''second argument given to FormatDateTime is vbLongDate=1
     next
     %>
            </select>
                  </td>
------------------------------------------------------------------------------
 
instead of the part
------------------------------------------------------------------------------
<td class="headingblue" width="74%" height="28">
                    <select size="1" name="StevesDate" style="font-size:
8pt" class="headingblue">
                      <%
     for i = weekd to 1 step -1
          curDate = dDate - weekd + i
          %>
              <option <%=curDate%>
value="1"><%=FormatDateTime(curDate,1)%></option>
              <%
          '''''second argument given to FormatDateTime is vbLongDate=1
     next
     %>
            </select>
                    <%
Sub fromSunday()
     Dim dDate, weekd, i, curDate
     dDate = date
     weekd = weekday(dDate)
   End Sub
     %>
                  </td>
------------------------------------------------------------------------------
-Deepa
 

Steve

unread,
Apr 20, 2002, 4:50:52 PM4/20/02
to
Thanks a bunch Deepa....works great!
 
I'm just starting out trying to program so thank you very much for helping me out.
 
Have a great weekend
 
Steve
"Deepa Jacob" <deepa_k...@hotmail.com> wrote in message news:OrPRqwK6BHA.2240@tkmsftngp04...

Steve

unread,
Apr 20, 2002, 5:59:53 PM4/20/02
to
Deepa,
 
Sorry to bug you...but I'm running into another issue :)   I want to insert the selected date into a table...but all it inserts is a "1"   I have tried changing the table data type from Date/Time to text...but still get a "1"   the DB is Access 2000...any ideas on how to accomplish this with your code?
 
Thanks
 
Steve
 
"Deepa Jacob" <deepa_k...@hotmail.com> wrote in message news:OrPRqwK6BHA.2240@tkmsftngp04...

Steve

unread,
Apr 20, 2002, 6:06:49 PM4/20/02
to
Please disregard the earlier post...I figured it out!
 
Thanks
 
Steve
0 new messages