Manny said:
Hi Can anyone tell me how i can calculate yesterday date using asp?
You've seen the VBScript solutions. Here's a JScript one:
var Now = new Date(),
Yesterday = new Date(
Now.getFullYear(),Now.getMonth(),Now.getDate()-1
)
The problem with your question is that neither VBScript nor JScript dates
are free of the time of day. Consider one alternative to the above:
var Yesterday = new Date(new Date().valueOf()-86400000)
The difference? The first example sets the time to 12:00:00 (midnight) --
the start of the day. The second dials the time back 24 hours, which means
it equals the first only once every 86,400,000 milliseconds.
And there is no difference when using VBScript. You cannot uncouple a date
from its time when using the native date object. This is especially
important when comparing dates.
Before deciding on any calculation of "yesterday", therefore, your usage
should drive your choice of calculation methods.
--
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.