473,473 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 10025
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: johkar | last post by:
I need to document.write out a select list populated with the dates for the first and third Wednesday of each month. How do I get to the actual days? <select name="mySelect"> <option value="Oct...
2
by: John | last post by:
If anyone can help me out with a good way to do this in javascript I would greatly appreciate it. I need to compute three dates in javascript - all of which relate to a given date, say todays...
13
by: SimonC | last post by:
I would like to return data from the last 2 weeks of each given month in Javascript, but in 2 formats. So, the penultimate week (Monday to Sunday) and the last week (Monday to ??) I'm not...
1
by: Martin Emanuelsson | last post by:
Hello, Knowing year and weeknumber of this year, I'm looking for some way to get the date of the first and last day of that particular week. Does anyone have an idea about how to do this? ...
2
by: Benz | last post by:
Hello all, Can anyone please tell me how to find the first and last date of a week when the year and the week number is given? The week model followed is the ISO model: Monday is the 1st day of...
0
by: Lee Harr | last post by:
I wrote a function to return the first date of a given week (and a few related functions) : -- return the first date in the given week CREATE or REPLACE FUNCTION week_start(integer, integer)...
9
by: rjfjohnson | last post by:
Hey, Today is Thursday 16-Feb-06. The same thursday last year is 17-Feb-05. Because I am comparing daily sales between years, I need to know the date of the same weekdayname as last year, so...
0
by: pratapmysql | last post by:
Hello All, I am trying to get same day (name) of week of last year in this case date of day is not constraint eg. if december 2007-12-19 day is wednesday ,then last year 2006 wednesday for same is...
1
by: peetersb | last post by:
Hi, I want ot make functions like this: int getFirtDayOfWeek(int weeknumber, int year); int getLastDayOfWeek(int weeknumber, int year); Firts I calculate the count of weeks like this: ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.