Click to See Complete Forum and Search --> : Calculating yesterday, tomorrow etc


LRHand
10-28-2003, 09:10 AM
I am trying to teach my students today, tomorrow etc. But when developing a test in JScript found that displaying the days was more difficult than I anticipated.

To calculate the day before yesterday I tried

day = today.getDay()-2;

But if today is a Sunday i.e. 0 it doesn't work.

I have tried an if else statement but that doesn't work either.

What should I do?

Vladdy
10-28-2003, 10:21 AM
day = (7+today.getDay()-2)%7;

LRHand
10-28-2003, 10:46 AM
Thank you so much, it works beautifully and so simple too!
:D