seconds portion of Time not writing correctly to database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having a problem with the seconds portion of time that I am writing to a
column in my VB .Net program. This is the code that populates a Sql
smalldatetime column.

ReportHistoryNewDataRow("rhDate") = Now

While running the debugger the value of Now is shown say for example as
8/19/2005 12:10:03 PM. But what actually is getting written to the database
is 8/19/2005 12:10:00 PM. Can anyone give me a clue as to why this is
happening?

Thanks.
 
This is because DateTime.Now gets the current system date time. A
solution to this problem: Store the current datetime beforehand in a
DateTime object and use this object where ever you need it.

HTH. Cheers.
Maqsood Ahmed [MCP C#,SQL Server]
Kolachi Advanced Technologies
http://www.kolachi.net
 
Back
Top