Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 816
  • Last Modified:

Deduct Days from Date

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
pvernon
Asked:
pvernon
1 Solution
 
pvernonAuthor Commented:
If any help the actual date is not displayed but is used in an SQL statement
0
 
drittichCommented:
What db are you using?
0
 
pvernonAuthor Commented:
SQL Server 7
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
drittichCommented:
Try

SELECT DATEADD(DD, -5, YOUR_DATE) FROM YOUR_TABLE
0
 
MisConFit8Commented:
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
 
Nitin SontakkeDeveloperCommented:
As drittich has already pointed out above,

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

seem to work fine.
0
 
Chandramouli kArchitectCommented:
u can use nextday function, if the db is in oracle.
0
 
Göran AnderssonCommented:
I figured the asp solution should at least be present, this is the asp thread, after all. ;)

datBefore=DateAdd("d", -5, Date())
0
 
Michel SakrCommented:
Simply

GetDate - 5

insert into tableName (zDateField) values (GetDate() - 5)
0
 
pvernonAuthor Commented:
Cool - thks very much!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now