views:

40

answers:

1

When I save a file 'last saved' date time in a SQL database, I cannot compare with a future scan directly -

eg if( SavedLastAccessDate <> FileSavedDate

I have to do this: DateTime fileSavedDateTime = System.IO.File.getLastWriteTime(filepath); TimeSpan gap = fileSavedDateTime - SavedLastAccessDateTime; if (gap.Milliseconds > ) { do something - new save }

does this make sense, when I save the last access in msSQL it adds .001 of a millisecond!!

Is there a better way?

+1  A: 

It does not add milliseconds - it just stores dates and times with limited precision.

Namely, datetimes are rounded to increments of .000, .003, or .007 seconds, whereas smalldatetime is even more rough with values that are 29.998 seconds or less are rounded down to the nearest minute and values of 29.999 seconds or more are rounded up to the nearest minute.

Anton Gogolev