Solved

Deduct Days from Date

Posted on 2002-06-21
10
765 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now