Re: Typed dataset: Time only data in SQL dateTime Field

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thanks Wen and Stephany,

This is indeed what I was looking for.

Dim SqlTimeOnly As Date = #12/30/1899#
SqlTimeOnly = SqlTimeOnly.Add(MyTime.TimeOfDay)

MyTableAdapter.Insert(sqlTimeOnly,yada,yada,yada)

This does in fact produce the outcome I wanted. When displaying the table
after insert only the time appears.

Thanks Again,

Jeff
"WenYuan Wang" wrote:

Hi Jeff,

I agree with Stephany. The DateTime filed always contains both date and
time parts. I'm afraid that it is not possible for us to only insert time
into DateTime type column. SQL Server inserts midnight (00:00:00) when time
information is missing, and 1900-01-01 when date information is missing.

But, under my test, in SQL 2000 if we set the date information to
"1899-12-30" SQL database will only display the time part of the field.
This is similar that you directly insert time into table by SQL Server
Enterprise Manager. I think maybe this is what you want.

For example:
Insert TableName into ([c1,c2]) values (1,' 1899-12-30 18:00')

In SQL database, the table will only show the time part of the field.
If you don't want to insert the day part into table, we suggest you can set
the date information to "1899-12-30".

I think this is the workaround to your issue.

Hope this will help.
Sincerely,
Wen Yuan


.



Relevant Pages

  • Re: SQL Server Parameters
    ... I understand what SQL Server is doing and it is doing as ... > have a missing param or misspelled it, ... >> a SQL error back that Procedure XYZ is expecting Parameter '@myParameter' ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: How to enable Windows Authentication
    ... either your missing something or I am missing something and I ... Windows Local User accounts. ... I remove the comments from the connection string in the web.config I can ... When connecting to SQL Server 2005, this failure may be caused by the ...
    (microsoft.public.dotnet.framework.aspnet)
  • Limit of 150 rows in a combobox?
    ... I can't find an answer to this in the newgroup postings, ... datasource is a SQL Server stored procedure. ... 200 rows when executed on SQL Server. ... Any advice on finding these missing rows would be most ...
    (microsoft.public.access.forms)
  • Re: Error 22272: Cannot load the DLL xpstar.dll...
    ... I would look for MSVCR71.DLL in SYSTEM32. ... I believe that if an entire DLL was missing, ... Reinstall the SQL Server tools? ...
    (comp.databases.ms-sqlserver)
  • Re: Recreate table - including new columns
    ... You are not missing anything. ... Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. ... > B. Recreate destination table > C. Pump in the data ... > The problem is that my DTS job ignores any new fields. ...
    (microsoft.public.sqlserver.dts)