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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DATE Questions 1

Status
Not open for further replies.

Ritsuke

Instructor
May 14, 2002
12
US
Hey all! =)

I'm trying to return the first day of the week (full date) once compared to a specific date.

So, from say today, 11/21/02 (defined from a query string result), I could get the first day of the week (Sunday as default first of week day) or 11/17/02.

Thank you for the help. =) 'you can't depend on your judgement when your imagination is out of focus' - mark twain
'we are all in the gutter, but some of us are looking at the stars.' - oscar wilde
 
Well, how about subtracting the current day of week from the current date + 1 ?
Code:
Dim firstDOW
firstDOW = dateAdd("d",WeekDay(Now)-1,Now)

Quick and clean :)
Hope that helps...
-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Thank you Tarwn for the quick response. =)

Unfortunately, I need to find the first day of the week when compared to any date, once given from the query sting.

So say I have &quot;?CurrentDay=&quot; <--- any date

currentDay = request.QueryString(&quot;CurrentDay&quot;)

From here, I need to take this value and find out the first day (default to sunday) of that particular week. So currentDay = 11/26/02 would return 11/24/02 after going through the missing piece to find it.

Thank you again for the help. =) I appologize for not being as clear in the first post. =( 'you can't depend on your judgement when your imagination is out of focus' - mark twain
'we are all in the gutter, but some of us are looking at the stars.' - oscar wilde
 
Here's what I came up with...A bit crude, but it seems to work. =) Anyone have any other ideas? I understand this is probablt not the best solution. =)

function finalDATE()
currentDayNumber = WeekDay(currentWeek)
currentSOW = DateDiff(&quot;d&quot;, currentDayNumber, currentWeek)
currentFOW = DateAdd(&quot;d&quot;, -currentDayNumber + 1, currentWeek)
currentEOW = DateAdd(&quot;w&quot;, 6, currentFOW)
Response.Write currentFOW & &quot; - &quot; & currentEOW
End Function 'you can't depend on your judgement when your imagination is out of focus' - mark twain
'we are all in the gutter, but some of us are looking at the stars.' - oscar wilde
 
Well, some minor alterations to my previous post should achieve what you were looking for as well:
Code:
Dim firstDOW, userDate
if isDate(Request.Form(&quot;txtDate&quot;))
   userDate = cDate(Request.Form(&quot;txtDate&quot;)
   firstDOW = dateAdd(&quot;d&quot;,(WeekDay(userDate)-1)*-1,userDate)
else
   Response.Write &quot;Invalid Date&quot;
end if

I apologize for the first post, I forgot to make the number negative like I did in the above function (*-1).
This should retrieve the previous sunday from the user entered date.
-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top