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

Date Issue

Status
Not open for further replies.

emissions

Technical User
Mar 17, 2002
68
0
0
GB
Hey all,

I've got a slight issue, I hope someone can help...

I have a date, that specify's and 'EventDate', what I looking to do, is work out from the 'EventDate', I want to work out what day is the first of that week.

I've tried looking on the web, and even looked at some asmples but can't quite hit the nail on the head.

THanks in advanced
 
not completely sure of what you want....

but look at dateadd() and datediff() functions...

-DNG
 
This writes the name of the weekday corresponding to the number.
response.Write(WeekDayName(1))

This writes the abbreviated name of the weekday corresponding to the number.
response.Write(WeekDayName(1,true))

Name of the current day of the week.
response.Write(WeekdayName(weekday(date)))

Abbreviated name of the current day of the week.
response.Write(WeekdayName(weekday(date), true))

You can pass in a date value as well like this:

mydate = "12/25/2005"
response.Write(WeekdayName(weekday(mydate)))

Paranoid? ME?? WHO WANTS TO KNOW????
 
Whoops, the FIRST day of that week? I missed that.

This shows the number of the day of the week.
<%response.write("Day of the week: "&WeekDay(Date))%>
In VBScript days of the week start at 1 on Sunday.

You can determine whatever you need to know by the number above.

The first day of the week is always sunday so not sure where you are actually going but this should get you started.


Paranoid? ME?? WHO WANTS TO KNOW????
 
If you were looking to determine what the DATE of the first day of the week of a given date is, this should do it for you.

This determines the day of the week indicated by startdate and subtracts the number of days past Sunday giving you the date corresponding to the first day of that week.

Code:
startdate = "11/24/2005"
weekstartdate = DATEADD("d",-(weekday(startdate)-1),startdate)


Paranoid? ME?? WHO WANTS TO KNOW????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top