Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: HOWTO: How do I find out what day of the week a specific date is?


Message #1 by Hal Levy <hal.levy@s...> on Wed, 25 Apr 2001 15:19:12 -0400
I am trying to find out what day of the week a month starts on. So I tried:



strDate = cdate("6/1/2001")

dayofweek = datepart("w", strDate)



Result: 

dayofweek=6



6 is Friday. A quick check of my calendar tells me that the month started on

Sunday- so I should get a 1 back. Obviously w doesn't do what I think it

does- so how do I do this?



Thanks,



Hal Levy

StarMedia Network, Inc.

Intranet Development Manager



Message #2 by Imar Spaanjaars <Imar@S...> on Wed, 25 Apr 2001 21:45:10 +0200
Hi Hal,



Is it possible that your system interprets 6/1/2001 as June 1st, instead of 

January 6th?



June 1 is indeed a Friday on my system.....



You might need to swap your date around a little.





Hope this helps,



Imar



P.S. January 6th is a Saturday on my system, which equals to 7 Are you 

using last year's calender?? ;-)





At 03:19 PM 4/25/2001 -0400, you wrote:

>I am trying to find out what day of the week a month starts on. So I tried:

>

>strDate = cdate("6/1/2001")

>dayofweek = datepart("w", strDate)

>

>Result:

>dayofweek=6

>

>6 is Friday. A quick check of my calendar tells me that the month started on

>Sunday- so I should get a 1 back. Obviously w doesn't do what I think it

>does- so how do I do this?

>

>Thanks,

>

>Hal Levy

>StarMedia Network, Inc.

>Intranet Development Manager



Message #3 by "O'Hara, Elliott M" <EMOHARA@k...> on Wed, 25 Apr 2001 15:35:29 -0400
CurrentDay = Weekday(date) 

DayCode = (currentday / currentday) 

StartDayCode = CurrentDay - DayCode 

mySunday = Dateadd("d", -StartDayCode, date)





-----Original Message-----

From: Hal Levy [mailto:hal.levy@s...]

Sent: Wednesday, April 25, 2001 3:19 PM

To: ASP Web HowTo

Subject: [asp_web_howto] HOWTO: How do I find out what day of the week a

specific date is?



I am trying to find out what day of the week a month starts on. So I tried:



strDate = cdate("6/1/2001")

dayofweek = datepart("w", strDate)



Result:

dayofweek=6



6 is Friday. A quick check of my calendar tells me that the month started on

Sunday- so I should get a 1 back. Obviously w doesn't do what I think it

does- so how do I do this?



Thanks,



Hal Levy

StarMedia Network, Inc.

Intranet Development Manager



Message #4 by Hal Levy <hal.levy@s...> on Wed, 25 Apr 2001 15:46:11 -0400
No- I am on the US dates.... Double checked... Weekday() has given me the

expected result.



Have I mentioned I hate calendar applications?



Hal Levy

StarMedia Network, Inc.

Intranet Development Manager



-----Original Message-----

From: Imar Spaanjaars [mailto:Imar@S...]

Sent: Wednesday, April 25, 2001 3:45 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Re: HOWTO: How do I find out what day of the

week a specific date is?





Hi Hal,



Is it possible that your system interprets 6/1/2001 as June 1st, instead of 

January 6th?



June 1 is indeed a Friday on my system.....



You might need to swap your date around a little.





Hope this helps,



Imar



P.S. January 6th is a Saturday on my system, which equals to 7 Are you 

using last year's calender?? ;-)



Message #5 by Shaun Steckley <SSTECKLEY@P...> on Wed, 25 Apr 2001 15:33:25 -0400
This is from MSDN...



Weekday Function

Returns a whole number representing the day of the week.



Weekday(date, [firstdayofweek])



Arguments

date



Any expression that can represent a date. If date contains Null, Null is

returned.



firstdayofweek



A constant that specifies the first day of the week. If omitted, vbSunday is

assumed.



Settings

The firstdayofweek argument has these settings:



Constant Value Description 

vbUseSystem 0 Use National Language Support (NLS) API setting. 

vbSunday 1 Sunday 

vbMonday 2 Monday 

vbTuesday 3 Tuesday 

vbWednesday 4 Wednesday 

vbThursday 5 Thursday 

vbFriday 6 Friday 

vbSaturday 7 Saturday 





Return Values

The Weekday function can return any of these values:



Constant Value Description 

vbSunday 1 Sunday 

vbMonday 2 Monday 

vbTuesday 3 Tuesday 

vbWednesday 4 Wednesday 

vbThursday 5 Thursday 

vbFriday 6 Friday 

vbSaturday 7 Saturday 





Remarks

The following example uses the Weekday function to obtain the day of the

week from a specified date: 



Dim MyDate, MyWeekDay

MyDate = #October 19, 1962#   ' Assign a date.

MyWeekDay = Weekday(MyDate)   ' MyWeekDay contains 6 because MyDate

represents a Friday.



-----Original Message-----

From: Hal Levy [mailto:hal.levy@s...]

Sent: Wednesday, April 25, 2001 3:19 PM

To: ASP Web HowTo

Subject: [asp_web_howto] HOWTO: How do I find out what day of the week a

specific date is?





I am trying to find out what day of the week a month starts on. So I tried:



strDate = cdate("6/1/2001")

dayofweek = datepart("w", strDate)



Result: 

dayofweek=6



6 is Friday. A quick check of my calendar tells me that the month started on

Sunday- so I should get a 1 back. Obviously w doesn't do what I think it

does- so how do I do this?



Thanks,



Hal Levy

StarMedia Network, Inc.

Intranet Development Manager



Message #6 by "Drew, Ron" <RDrew@B...> on Thu, 26 Apr 2001 13:47:25 -0400
var dayNames = new Array(

"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); 

document.write(dayNames[now.getDay()]);



Replace now  with your date..





-----Original Message-----

From: Hal Levy [mailto:hal.levy@s...]

Sent: Wednesday, April 25, 2001 3:19 PM

To: ASP Web HowTo

Subject: [asp_web_howto] HOWTO: How do I find out what day of the week a

specific date is?





I am trying to find out what day of the week a month starts on. So I tried:



strDate = cdate("6/1/2001")

dayofweek = datepart("w", strDate)



Result: 

dayofweek=6



6 is Friday. A quick check of my calendar tells me that the month started on

Sunday- so I should get a 1 back. Obviously w doesn't do what I think it

does- so how do I do this?



Thanks,



Hal Levy

StarMedia Network, Inc.

Intranet Development Manager


  Return to Index