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

how to add days to the due date 1

Status
Not open for further replies.
May 17, 2006
54
US
Macola version 7.6.400a

I would like to change some of my open AP item's due dates by adding 83 days to the trx_dt. In other words due_dt=trx_dt + 83 days.

This is simple when the date is stored as a date format, but how do you do it when the date is in yyyymmdd format?

P.S. I know how to create terms codes to do this, my users do not however and I need to correct some entries they already entered.

Thanks....
 
In order to accurately add days to a YYYMMDD date, you'll need to convert it to a date e.g.

Code:
select trx_dt, dateadd(d,83,cast(cast(trx_dt as varchar) as datetime)) from APOPNFIL_SQL

Once you see that the resulting date is OK, you then need to convert it back to YYYMMDD format e.g.

Code:
select trx_dt, convert(varchar(8), (dateadd(d,83,cast(cast(trx_dt as varchar) as datetime))), 112) from APOPNFIL_SQL

When you're OK with that, it's simply a case of updating the due date with the results e.g.

Code:
update APOPNFIL_SQL set due_dt = convert(varchar(8), (dateadd(d,83,cast(cast(trx_dt as varchar) as datetime))), 112)



Peter Shirley
Macola Consultant, PA and surrounding states.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top