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

SQL Insert New Dates

Status
Not open for further replies.

jlbucs55

Technical User
Mar 12, 2002
4
US
I am having a hard time with writing a statement that will automatically insert a new date (30 days out) and forcast ID. I have tried an insert statement and update statement, but none of them will work.

This section is part of the module I am trying to build. Can anyone see an error in this section? Should the str go elsewhere?

Set rsDistinctForcasts = mydb.OpenRecordset("QRY_DISTINCT_FORCAST_IDS")
With rsDistinctForcasts
If Not .EOF Then
Do Until .EOF
strSQL = "SELECT MAX(FORCAST_OT_DATE) AS MAX_DATE FROM TBL_FORCASTS_OT_DATES WHERE FORCAST_ID = " & !ForcastID
Set rsMaxDate = mydb.OpenRecordset(strSQL)
datMaxDate = rsMaxDate!MAX_DATE
lngDateDiff = DateDiff("d", datMaxDate, datCurrDate)

For i = 0 To lngDateDiff
strSQL = "Tried insert and update here "
Next

.MoveNext
Loop
End If
End With
 
if your date is stored as a date field and not plain text, you can do something like this to add 30 to your date

INSERT INTO TBL_FORCASTS_OT_DATES (FORCAST_OT_DATE) Values (FORCAST_OT_DATE + 30)

basically you can any integer value to a date field in an sql statement.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top