Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add days to a date?

Status
Not open for further replies.

msquires

Programmer
Aug 8, 2000
7
0
0
GB
Hi, does anyone know whether its possible to add 30/60 or 90 days to a date in a SQL statement?<br><br>e.g. Add 30 days to 1/06/2000 would equate to 1/07/2000.<br><br>Thanks<br><br>Mike
 
Depends on what flavor of SQL you are using.&nbsp;&nbsp;&nbsp;The following examples add 30 days to todays system date:<br><br>Oracle - <br>SYSDATE + 30<br><br>Access - <br>DateAdd('d', 30, DATE())<br><br>Those are the two I know.&nbsp;&nbsp;&nbsp;Hope it helps...<br><br> <p>Terry M. Hoey<br><a href=mailto:th3856@txmail.sbc.com>th3856@txmail.sbc.com</a><br><a href= > </a><br>
 
Ingres: -<br><br>date('today' + '30 days'); <p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>
 
I'm specifcally looking at implementing the field in MySQL and SQL Server. Does anyone have any ideas on how this could be done?
 
SQL Server doesn't have a date datatype, just datetime and smalldatetime.&nbsp;&nbsp;<br>DATEADD(day, 30, GETDATE()) adds 30 days to the current system datetime.<br>There is a time value associated with that, so to get rid of that<br>DATEADD(day, 30, CONVERT(char(10),GETDATE(),101)) adds 30 days to the current system date. <p>Malcolm Wynden<br><a href=mailto:wynden@island.dot.net>wynden@island.dot.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top