469,898 Members | 1,538 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

ASP - first and last day of each week in a year


Hi,

is it possible to determine the first and the last day of a week (with
classic ASP)

nu = "06/01/2008"
week = (DatePart("ww",nu))

firstday = dateadd("d",(-datepart("w",date())),nu)
lastday = dateadd("d",(7-datepart("w",date())),nu)

response.write week
response.write "<br>"
response.Write firstday
response.write "<br>"
response.Write lastday

'week' must give me the number of the week for the date in 'nu'
'firstday' must give me the first date of that week
'lastday' must give me the last date of that week

it won't work

is there a way to do this?

thanks in advance

Jan 4 '08 #1
4 9446
this has some example code for vbscript and first day of week appears on pg 317
Jan 4 '08 #2
try again..

http://tinyurl.com/yv538d

"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot comwrote in message news:13*************@corp.supernews.com...
this has some example code for vbscript and first day of week appears on pg 317

Jan 4 '08 #3
Charlotte wrote on 04 jan 2008 in
microsoft.public.inetserver.asp.general:
>
Hi,

is it possible to determine the first and the last day of a week (with
classic ASP)

nu = "06/01/2008"
This is dangerous, did you mean the first of june, nee toch?

Use:

nu = #2008/01/06#

So now nu is a date object and you are sure to have 'overmorgen'.
week = (DatePart("ww",nu))
week = Weekday(nu, 1)

[1 means sunday is the first day of the week,
so 1 = sunday, 7 is saturday]
firstday = dateadd("d",(-datepart("w",date())),nu)
firstday = dateadd("d", 1 - week, nu)
lastday = dateadd("d",(7-datepart("w",date())),nu)
lastday = firstday + 6
response.write week
response.write "<br>"
response.Write firstday
response.write "<br>"
response.Write lastday

'week' must give me the number of the week for the date in 'nu'
'firstday' must give me the first date of that week
'lastday' must give me the last date of that week

it won't work
Never say that in a NG like this,
show error texts and what you did to debug.
is there a way to do this?

thanks in advance
so use this:

nu = #2008/01/09#
week = Weekday(nu, 1)
firstday = dateadd("d", 1 - week, nu)
lastday = firstday + 6
Succes,

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 4 '08 #4
tim
Charlotte,

A lot of information how to work with dates is to be found on the following
website.
http://www.chrispearson.org/pages/pr...sc/weekday.asp

Good luck
Tim

"Charlotte" <ch***************@SPAMtelenet.beschreef in bericht
news:SG*********************@phobos.telenet-ops.be...
>
Hi,

is it possible to determine the first and the last day of a week (with
classic ASP)

nu = "06/01/2008"
week = (DatePart("ww",nu))

firstday = dateadd("d",(-datepart("w",date())),nu)
lastday = dateadd("d",(7-datepart("w",date())),nu)

response.write week
response.write "<br>"
response.Write firstday
response.write "<br>"
response.Write lastday

'week' must give me the number of the week for the date in 'nu'
'firstday' must give me the first date of that week
'lastday' must give me the last date of that week

it won't work

is there a way to do this?

thanks in advance

Jan 8 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by johkar | last post: by
1 post views Thread by Martin Emanuelsson | last post: by
reply views Thread by Lee Harr | last post: by
9 posts views Thread by rjfjohnson | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.