I have a date field in the database that store values in format mm/dd/yyy. Using this how can I get the first and the last day of a given date. I m using this following code to display records from database
<%
sql="select * from order_details where emp_name= "&session("emp")&" order by 1,2,3,4,5,6,7"
rs.open sql,con,1,2
do while not rs.eof
session("wk")=weekdayname(weekday((rs("date"))))
%>
<tr>
<td align="center"><%=rs("emp_name")%></td>
<td align="center"><%=rs("food_had")%></td>
<td align="center"><%=rs("quantity")%></td>
<td align="center"><%=session("wk")%></td>
<td align="center"><%=day(rs("date"))&"/"&month(rs("date"))&"/"&year(rs("date"))%></td>
<td align="center"><%=rs("grand_total")%></td>
</tr>
<%
rs.movenext
loop
rs.close
%>
“会议”给我一个星期日的名称。
Now That I have the code I edited the query so that i can use firstdayofthemonth and lastdatofthemonth to display records but its not working this is what I used
<%
sql="select * from order_details where emp_name= "&session("emp")&" and date BETWEEN "&session("firstDayOfMonth")&" AND "&session("firstDayOfMonth")&" "
rs.open sql,con,1,2
do while not rs.eof
session("m")=monthname(month((rs("date"))))
session("firstDayOfMonth") = rs("date") + 1 - day(rs("date"))
session("lastDayOfMonth") = dateadd("m", 1, session("firstDayOfMonth") ) - 1
%>
<tr>
<td align="center"><%=rs("emp_name")%></td>
<td align="center"><%=rs("food_had")%></td>
<td align="center"><%=rs("quantity")%></td>
<td align="center"><%=session("wk")%></td>
<td align="center"><%=day(rs("date"))&"/"&month(rs("date"))&"/"&year(rs("date"))%></td>
<td align="center"><%=rs("grand_total")%></td>
<td align="center"><%=session("firstDayOfMonth")%></td>
<td align="center"><%=session("lastDayOfMonth")%></td>
</tr>
<%
rs.movenext
loop
rs.close
%>
if I remove "and date BETWEEN "&session("firstDayOfMonth")&" AND "&session("firstDayOfMonth")&" " from the query shows the first and the last date...but I want to display records using firstdate and lastdate ...am I misssing something in my query on top..