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.

Re: seconds portion of Time not writing correctly to database by Maqsood

Maqsood
Fri Aug 19 23:45:47 CDT 2005

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

*** Sent via Developersdex http://www.developersdex.com ***

Re: seconds portion of Time not writing correctly to database by WishingIwasskiingmom

WishingIwasskiingmom
Mon Aug 22 10:04:05 CDT 2005

Hmmm...
Well I tried your suggestion as follows.
Dim datetime As Object = Today.Now
ReportHistoryNewDataRow("rhDate") = datetime
and am receiving the same results, still a 00 value for seconds.
Any other suggestions?

"Maqsood Ahmed" wrote:

> 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
>
> *** Sent via Developersdex http://www.developersdex.com ***
>

Re: seconds portion of Time not writing correctly to database by WishingIwasskiingmom

WishingIwasskiingmom
Mon Aug 22 10:36:53 CDT 2005

Hi Maqsood,
I tried actually updating this field using Query Analyzer and ended up with
the same results, seconds = 00, so I changed the field type to datetime
rather than smalldatetime and it worked.
Thanks.


"Maqsood Ahmed" wrote:

> 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
>
> *** Sent via Developersdex http://www.developersdex.com ***
>