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

Dec 31 04 & Jan 01 05 both show weekday as Sat 1

Status
Not open for further replies.

jlsmithhartfiel

Programmer
Jan 7, 2002
336
US
How can these both show as Saturday? 12/31/04 was a Friday. It's messing up my reporting...argh!

Code:
Response.Write "<br>Dec 31 " & WeekdayName(weekday(12/31/04),7)
Response.Write "<br>Jan  1 " & WeekdayName(weekday(1/1/05),7)


TIA,

Jessica [ponytails2]
 
response.write weekdayname(weekday(formatdatetime("1/1/2005")))
 
Indeed, that's the correct answer.

And since datetime conversion is usually implicit anyway, even this should work:
Code:
Response.Write "<br>Dec 31 " & WeekdayName(weekday([COLOR=blue]"[/color]12/31/04[COLOR=blue]"[/color]),7)
Response.Write "<br>Jan  1 " & WeekdayName(weekday([COLOR=blue]"[/color]1/1/05[COLOR=blue]"[/color]),7)
What you had was 12 divided by 31 divided by 4, a very small number which was then converted into a date, and 1 divided by 1 divided by 5, which was also converted into a date.
 
so really in other words, the only thing he did wrong was that he forgot to put the date in quotes..
 
Thanks!

That cleared up that test. I thought I was losing my mind.

I then realized how in "reality" the code is failing. The previous programmer was only using 1/1 and not including the year - :(

Thanks again!

Jessica [ponytails2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top