Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get days of week according to Date chosen 1

Status
Not open for further replies.

gradinumcp

IS-IT--Management
Apr 6, 2005
85
US
Hi! I have a piece of code where the user picks a date from the calendar. Depending on the date he has picked, it should display all the days of the week.

Example: If the user picked 18th October 2005 from the calendar, then it should display:

Sunday 10/16/2005
Monday 10/17/2005
Tuesday 10/18/2005
Wednesday 10/19/2005
Thursday 10/20/2005
Friday 10/21/2005
Saturday 10/22/2005


I know this can be displayed if the date picked is todays date by using <%=Date()-Weekday(Date())+1%> for Sunday and so on.

However how do i accomplish this when the Date is what the user has picked--so kind of change Date() to say <%=request("PullDate")%>--but what would be the correct code for that??

Here's my code:

<td>Week<input class=fields readonly name="PullDate" <% if request("PullDate")<>"" then %>value="<%=request("PullDate")%>"<% else %>value="<%=Date()%>"<% end if %>

Sunday=<%=Date()-Weekday(Date())+1%>
Monday=<%=Date()-Weekday(Date())+2%>
Tuesday=<%=Date()-Weekday(Date())+3%>
Wednesday=<%=Date()-Weekday(Date())+4%>
Thursday=<%=Date()-Weekday(Date())+5%>
Friday=<%=Date()-Weekday(Date())+6%>
Saturday=<%=Date()-Weekday(Date())+7%>
 
You can put it like this.
[tt]
dim sdt,ddt
sdt=request("pulldate")
if isdate(sdt) then
ddt=cdate(sdt)
else
ddt=date
end if
[/tt]
The rest follows the same logic.
[tt]
Sunday=<%=ddt-Weekday(ddt)+1%>
Monday=<%=ddt-Weekday(ddt)+2%>
Tuesday=<%=ddt-Weekday(ddt)+3%>
Wednesday=<%=ddt-Weekday(ddt)+4%>
Thursday=<%=ddt-Weekday(ddt)+5%>
Friday=<%=ddt-Weekday(ddt)+6%>
Saturday=<%=ddt-Weekday(ddt)+7%>
[/tt]
(There could be some dependency on localization.)
 
Works Like a charm--Thanks a bunch--i have been trying to figure this out for almost 2 days and couldn't get it out of my head even over the weekend. Now I get to enjoy the Week atleast:))

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top