Dates get rounded when passed to Sql Server with time component

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hello,

I needed to get the last day in the month. I used a very basic formula which
essentially subtracted 3 seconds from the 1st day of the following month.
This gave me a string like "#7/31/2006 11:59:57PM".

I then passed this to an sql server parameter as its value for a query.

..Item("@PeriodEnd").Value = CDate(reports.SAPR(i).PeriodEnd)

I found i kept getting a value in the database of 08.01.2006 or 1st of
august.????

So i debug to the line

..Item("@PeriodEnd").Value = CDate(reports.SAPR(i).PeriodEnd)

and use the immediate windown to get the value

?CDate(reports.SAPR(i).PeriodEnd)

and it still reads

"#7/31/2006 11:59:57PM".

I have fixed my bug by rounding out the date before it even gets to the
query so im not interested in fixes but rather would like to find out why
the date is rounding in the first place between .net 2.0 and sql server.

This may affect me in other ways so please advise or provide a link to this
intended or unintended behaviour. I did not know this gets rounded. Did you?

Thanks

stano


.



Relevant Pages

  • Re: Dates get rounded when passed to Sql Server with time component
    ... I then passed this to an sql server parameter as its value for a query. ... the date is rounding in the first place between .net 2.0 and sql server. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: CONTAINS performance
    ... That said, and with the query plan, I can start to give you more ... relational join in the context of the free-text optimization, ... SQL Server tables. ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Access to SQLServer GCE
    ... Actually, as Larry points out, the Access client does a good job of filtering only information that you need. ... If your query is bound to a report, and you open that report supplying a typical "where" for that report, then Access will NOT pull down all the records, but in most cases Access will only pull down the required records and respect your filter. ... So SQL server will respect the conditions and filtering placed into those queries, and therefore only pull down those records you require. ... The suggestion in these cases is to consider using a pass-through query since all of that summing is done before the row comes down the network pipe. ...
    (comp.databases.ms-access)
  • Re: Indexing Service, Openquery and sp_executesql
    ... SQL Server version and sp are you running? ... > data from the indexing service catalog when pasted into ... > query analyzer, but failed when put against sp_executesql ... I would choose Microsoft Indexing ...
    (microsoft.public.sqlserver.fulltext)
  • Re: Problem using Access or Query Designer to run queries in SQL Serve
    ... >or Query Designer within Enterprise Manager, it works and I get data back. ... >ODBC Call Failed [ODBC SQL Server Driver] Timeout Expirederror in Access ... >[ODBC SQL Server Driver] Timeout Expired ...
    (microsoft.public.sqlserver.odbc)