datetime

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nbohana

    #1

    datetime

    I am using C#, Windows forms and SQL Server. Part of the data that I am
    having problems with is defined as datetime. When I insert the field into
    the datebase it is formated as "MM/dd/yyyy", and the data stored in the
    database looks like this "06/07/2005". When I open the form and fill the
    dataset the date looks like this "06/07/2005 12:00 PM". the question is what
    do I do to get rid of the time which is not correct. Help!!!
    --
    Norm Bohana
  • John B

    #2
    Re: datetime

    nbohana wrote:[color=blue]
    > I am using C#, Windows forms and SQL Server. Part of the data that I am
    > having problems with is defined as datetime. When I insert the field into
    > the datebase it is formated as "MM/dd/yyyy", and the data stored in the
    > database looks like this "06/07/2005". When I open the form and fill the
    > dataset the date looks like this "06/07/2005 12:00 PM". the question is what
    > do I do to get rid of the time which is not correct. Help!!![/color]

    There is no such thing as a Date structure, only datetime.
    You would need to format the form to only display the date part
    (MM/dd/yyyy) instead of the datetime.

    JB

    PS. By default the time portion of the datetime should be 0.00.00.00 (12
    AM).
    I have come across times where the current time was used when not
    specified though (IIRC).

    Comment

    • Daya PSP

      #3
      RE: datetime

      Hi,
      you can convert it to shortdate string like the one below,

      dap.Fill(ds);
      DateTime dd =Convert.ToDate Time(ds.Tables[0].Rows[0].ItemArray[0].ToString());
      textBox1.Text = dd.ToShortDateS tring();

      regards, Daya PSP India

      "nbohana" wrote:
      [color=blue]
      > I am using C#, Windows forms and SQL Server. Part of the data that I am
      > having problems with is defined as datetime. When I insert the field into
      > the datebase it is formated as "MM/dd/yyyy", and the data stored in the
      > database looks like this "06/07/2005". When I open the form and fill the
      > dataset the date looks like this "06/07/2005 12:00 PM". the question is what
      > do I do to get rid of the time which is not correct. Help!!!
      > --
      > Norm Bohana[/color]

      Comment

      • John B

        #4
        Re: datetime

        Daya PSP wrote:[color=blue]
        > Hi,
        > you can convert it to shortdate string like the one below,
        >
        > dap.Fill(ds);
        > DateTime dd =Convert.ToDate Time(ds.Tables[0].Rows[0].ItemArray[0].ToString());[/color]

        If its in the dataset as a boxed datetime, why would you convert it to a
        string first?

        DateTime d = (DateTime)ds.ta bles[0].rows[0].itemarray[0];
        [color=blue]
        > textBox1.Text = dd.ToShortDateS tring();[/color]

        That sounds good though :)

        JB[color=blue]
        >
        > regards, Daya PSP India
        >
        > "nbohana" wrote:
        >
        >[color=green]
        >>I am using C#, Windows forms and SQL Server. Part of the data that I am
        >>having problems with is defined as datetime. When I insert the field into
        >>the datebase it is formated as "MM/dd/yyyy", and the data stored in the
        >>database looks like this "06/07/2005". When I open the form and fill the
        >>dataset the date looks like this "06/07/2005 12:00 PM". the question is what
        >>do I do to get rid of the time which is not correct. Help!!!
        >>--
        >>Norm Bohana[/color][/color]

        Comment

        Working...