Re: Storing only timepart in Sql server datetime

From: M O J O (mojo_at__no_spam_delete_this_newwebsolutions.dk)
Date: 09/02/04


Date: Thu, 2 Sep 2004 07:40:14 +0200

Hi Grogory,

I'm doing this already today, but with Delphi. Now I'm using VB.Net and want
to do the same.

I'm using a DateTime field in MS SQL 2000, and by using Delphi's Frac method
(eg. Frac(SomeDateTimeVar)), it is stored in SQL server only showing the
time (when running a query).

I'm not looking for a Time field in SQL, I only want to store the Time in a
datetime.

M O J O

"Cowboy (Gregory A. Beamer) - MVP" <NoSpamMgbworld@comcast.netNoSpamM> skrev
i en meddelelse news:F8099FD9-CA17-40BC-BDC3-C6F5062DF021@microsoft.com...
> Currently, there is no way to do it in this type of field. Even if you set
> everything to 0 plus time, you will have a date portion.
>
> In SQL 2005, you can create a UDT, but in SQL 2000, you are pretty much
> stuck with setting up a character data type for the time portion only.
> Eventually, you MAY have a time data type, but it is not going to be in
the
> initial 2005 release (for understandable reasons, BTW).
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
> "M O J O" wrote:
>
> > Hi,
> >
> > How do I store only the time part in a sql server datetime field?
> >
> > I've tried using ....
> >
> > Params.Add("@MyField", SqlDbType.DateTime, DateTime.Parse("00:05:00"))
> >
> > .... but it stores this value "01-09-2004 00:05:00".
> >
> > I want to store "00:05:00".
> >
> > Any idea???
> >
> > Thanks!!!
> >
> > M O J O
> >
> >
> >



Relevant Pages

  • Re: Typed dataset: Time only data in SQL dateTime Field
    ... I can type in a Time alone directly into a sql DateTime field. ... I need to retain the format as it was in access. ... how be able to provide input to my typed dataset to replicate the behavior. ... I also noticed that the Sql import was able to replicate this format. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Information between specific dates
    ... a dateTime field. ... After you answer that perhaps you can post the SQL view of your query. ... Access MVP 2002-2005, 2007-2008 ... Center for Health Program Development and Management ...
    (microsoft.public.access.queries)
  • Re: UPDATING/INSERTING DATETIME FIELDS FROM ASP?
    ... I think I will need to use calculations at some point, is there a way to pass the Nowvalue into the datetime field. ... I would have used the timestamp but it isn't available on my SQL server. ... Please reply to the newsgroup. ...
    (microsoft.public.inetserver.asp.db)
  • Re: Typed dataset: Time only data in SQL dateTime Field
    ... typed dataset. ... We are in the process of moving from access to Sql 2000. ... I now have 2 typed datasets one pointing to a table in access and one ... DateTime field expected to have only a time in it. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Datatime type data error when wrte the dateime type information from XML to SQLCE
    ... a DateTime field. ... The CONVERT function in SQL CE does not ... have a format style for this either. ... >I write SQLCE DATA to XML. ...
    (microsoft.public.pocketpc.developer)