473,797 Members | 3,183 Online
Bytes | Software Development & Data Engineering Community
+ 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",da te())),nu)
lastday = dateadd("d",(7-datepart("w",da te())),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 10085
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.supe rnews.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.publi c.inetserver.as p.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",da te())),nu)
firstday = dateadd("d", 1 - week, nu)
lastday = dateadd("d",(7-datepart("w",da te())),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******** *************@p hobos.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",da te())),nu)
lastday = dateadd("d",(7-datepart("w",da te())),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
9630
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 1, 2003">Oct 1, 2003</option> <option value="Oct 15, 2003">Oct 15, 2003</option> .....and so on for a continual 12 month period </select> Thanks,
2
9566
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 date. I need to calculate: 1. same day last year(that is, if today is friday, i want the date of the friday 52 weeks ago)
13
3622
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 sure if it can be done, but all help welcomed. E.g. I have December and would like to see the last 2 weeks.. So this doesnt mean the last 15 days. What i mean by this is...
1
2889
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? Best regards Martin
2
3861
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 the week and the 1st week should have atleast 4 days. I got to see one thread on this topic, but it doesnt work.. there are problems with it when an year has 52 or 53 weeks in it....
0
2866
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) RETURNS date AS ' DECLARE pyear ALIAS FOR $1; pweek ALIAS FOR $2;
9
2402
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 that I am comparing Saturdays with Saturdays, Sundays with Sundays, etc ie, 16-feb-06 goes to 17-feb-05 28-july-06 goes to 27-july-05 and so on
0
2005
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 on date 2006-12-20 here day is constarint. i.e. we need to match same day of that week . i have tried a stored procedure to find it, but it doest work as per expectation anyone has query in mysql to find same day of week of last year then help me...
1
2611
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: DateTime lastDay = new DateTime(DateTime.Now.Year, 12, 31);
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10469
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10246
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10023
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7560
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6803
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5459
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3750
muto222
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.