Solved

Deduct Days from Date

Posted on 2002-06-21
10
776 Views
Last Modified: 2011-09-20
Quick question,

Is there a quick function to deduct 5 days from the current date to give the date well... 5 days ago - or do I need to do a deduct on the days then ammend the month/year accordingly?
0
Comment
Question by:pvernon
10 Comments
 

Author Comment

by:pvernon
ID: 7098900
If any help the actual date is not displayed but is used in an SQL statement
0
 
LVL 8

Expert Comment

by:drittich
ID: 7098930
What db are you using?
0
 

Author Comment

by:pvernon
ID: 7098948
SQL Server 7
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Accepted Solution

by:
drittich earned 100 total points
ID: 7099029
Try

SELECT DATEADD(DD, -5, YOUR_DATE) FROM YOUR_TABLE
0
 

Expert Comment

by:MisConFit8
ID: 7099646
That will select your date and add 5 to it.  However, if you want to select something that is 5 day ago or 5 days from now in your db, there is a better/cleaner way.  What are you trying to accomplish?
0
 
LVL 9

Expert Comment

by:Nitin Sontakke
ID: 7099704
As drittich has already pointed out above,

SELECT DateAdd(dd, -5, getDate())

seem to work fine.
0
 
LVL 5

Expert Comment

by:kcm76
ID: 7100266
u can use nextday function, if the db is in oracle.
0
 
LVL 29

Expert Comment

by:Göran Andersson
ID: 7100388
I figured the asp solution should at least be present, this is the asp thread, after all. ;)

datBefore=DateAdd("d", -5, Date())
0
 
LVL 20

Expert Comment

by:Silvers5
ID: 7100392
Simply

GetDate - 5

insert into tableName (zDateField) values (GetDate() - 5)
0
 

Author Comment

by:pvernon
ID: 7101617
Cool - thks very much!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question