Link to home
Start Free TrialLog in
Avatar of FCapo
FCapo

asked on

Access Sql Date Vb

Hi,

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 vb.net 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?
Avatar of Jared_S
Jared_S

You can use templates for your update/edit that excludes the calculated value from your update command.
Avatar of FCapo

ASKER

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?
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

Alan
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial