473,714 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculate Yesterday Date

Hi Can anyone tell me how i can calculate yesterday date using asp?


Jul 19 '05 #1
4 10111

yesterday=datea dd("d",-1,date)

"Manny Chohan" <Ma*********@di scussions.micro soft.com> wrote in message
news:EB******** *************** ***********@mic rosoft.com...
Hi Can anyone tell me how i can calculate yesterday date using asp?



Jul 19 '05 #2
Manny Chohan wrote:
Hi Can anyone tell me how i can calculate yesterday date using asp?



Depends on which scripting language you wish to use. VBScript is the
default, so here is a vbscript solution:

dYesterday = DateAdd("d",-1,Date())

Bob Barrows

Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #3
considering the variable has a date as "date" type:

myDate = myDate - 1

Manohar Kamath
Editor, .netWire
"Manny Chohan" <Ma*********@di scussions.micro soft.com> wrote in message
news:EB******** *************** ***********@mic rosoft.com...
Hi Can anyone tell me how i can calculate yesterday date using asp?



Jul 19 '05 #4
Manny Chohan wrote:
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.
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: David | last post by:
Can someone help me with this. I need to calculate the week ending date of the first week of the year based upon a year provided by the user. Is there a simpler way other than writing my own UDF?
by: Laery | last post by:
Hi, I'm currently adding a new module to an old borland C3.1 application (dos). And I need to calculate a date by subtracting the number of days from a given date. I know I could use an array of days in the months and go back by leaping when 1 is reached. (keeping the 29the of feb and january/year in mind).
by: Steve | last post by:
Hi all How would I find out the average date when given a bunch of dates? For example, I want to find the average length in time from the following dates: ---------------------------------------------------- Start Date End Date 01/01/2004 12:50pm 02/01/2004 18:40pm 02/01/2004 13:40pm 02/01/2004 13:57pm 02/01/2004 14:30pm 02/01/2004 19:50pm
by: Li Pang | last post by:
Hi, In VB6 I used Now() -1 to get yesterday, but it's not allowed in vb.NET. Is there a similar way to do it in vb.Net? Thanks in advance
by: Amanda | last post by:
This is hotel reservation when a departure date is changed manually by user input ( to a valid date in date format - validity is checkedsomewhere else), the arrival date is set to the previous date upon MouseLeave. How do I calculate the date of the previous day (see mdatArrivalDate = ???? )? (I have already done calculating departure date when an arrrivalDate is modified manually - not via selecting on calendar - to valid data by...
by: fatmir | last post by:
i wont to calculate the date for example: 22.09.1999 today:02.07.2007 -------------------------- day.month.year(day.month.8 year) please help me
by: karthickkuchanur | last post by:
Hai, I have the doubt that how to make query like I have the start date and date I suppose to calculate the the days from start date for example if the date is25/02/2008.i have prepare the report for 13 days after the start date HOw can write the query for next 13 days i use the Dateadd function but i cant able to phase the query select startdate from ClientRegister between( DateAdd(day,13,startdate)...
by: shimul | last post by:
Hi All, If I set up a form with start date (choose from calendar) and end date. Each week Start date (Monday ) and want to automatically calculate end date (sunday each week) . how can I calculate an end date field and place it in the form, It really giving me hard time, can someone help please? As example start date : 2008/12/08, end date : 2008/12/14 Thank you.
by: Jared Elyea | last post by:
I had no experience in VB before writing this so bare with me... the function below seems to work for certain cases, but not all (in some cases it is a week behind). Can anybody help me figure this out? It is supposed to take an integer(numDays) and a date and calculate the date that is "numDays" weekdays from the start date. I don't know if it is the if statement at the bottom or the particular cases that seem not to work. Here it is it...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.