Access Sql Date Vb


I added a dateDiff to my sql statement:
dateDiff('d', recevDateBillSent, NOW()) AS DiffDate

Open in new window

My dataset is binding to my datagridview, this date difference field has been added as an extra column in my datagridview, but when I try to update other columns in my dataset there is a Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.

I'm guessing it is because is trying to save the dateDiff column in to my database but there is no column to save to because it is created through the sql statement.

Is there a way around this?
Who is Participating?
You will need to generate the Update command of adapter manually.
You can use templates for your update/edit that excludes the calculated value from your update command.
FCapoAuthor Commented:
I'm basically trying to filter only the records where a date is either smaller or equal then itself - 7 days.

for example :

recAccessBindingsource.Filter = "recevDateBillSent <= '%recevDateBillSent - 7%'"

but obviously this doesn't work, would there be a way to do this without using SQL?
Alan WarrenApplications DeveloperCommented:
Sql would be the place to apply the filter:
SELECT Table1.* FROM Table1 WHERE ((DateDiff("d",[The_Date_Field],Date())<=7));

Open in new window

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.

All Courses

From novice to tech pro — start learning today.