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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I increment a date, say, '02

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How do I increment a date, say, '02.11.98' by a month to get '02.11.98'?????
thanx

ps. doesn't have to be SQL...visual basic would be fine too, just that the date would be in a field(database) and the incremented date would also be stored in a field so I gathered....SQL!!!:)
 
Use function DateAdd. In this function, you specify how much to increment, and what, date, month, year. John Fill
ivfmd@mail.md
 
Agree with John, if you're using Sybase or MS SQL Server, the syntax is probably;

datedd(mm,1,getdate()

to add 1 month to the current date.

Greg.
 
Sorry, that should be

dateadd(mm,1,getdate())

Greg.
 
Hi, in Oracle PL/SQL you can use add_months function:

in a variable assignment: new_date:= add_months(old_date,1);
or
in a select statement: SELECT add_months(old_date,1) new_date FROM your_table;

Off course, this works for variable or column of date datatype. If you have columns which store date in string format, you have to apply convertion (cast) like to_date function (again, in PL/SQL).
Eduard Stoleru
e_stoleru@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top