Results 1 to 4 of 4

Thread: Datetime field conversion

  1. #1
    Irene Guest

    Datetime field conversion

    Hello, I would appreciate any suggestions
    I've got a datetime field that I'd like to store as just the date without the time component, but still to keep it defined as a datetime field. I ran this update statement but this conversion isn't working. Conversion to char gives me what I want but I need to keep the field as a date datatype if possible.
    Thanks

    update
    <table>
    set
    <column>=convert(datetime,convert(char(10),hire_da te,101)))


  2. #2
    BL Guest

    Datetime field conversion (reply)

    Concatenate 3 datepart functions and a fixed &#39;00:00:00.000&#39; expression.


    ------------
    Irene at 8/8/00 12:03:23 PM

    Hello, I would appreciate any suggestions
    I&#39;ve got a datetime field that I&#39;d like to store as just the date without the time component, but still to keep it defined as a datetime field. I ran this update statement but this conversion isn&#39;t working. Conversion to char gives me what I want but I need to keep the field as a date datatype if possible.
    Thanks

    update
    <table>
    set
    <column>=convert(datetime,convert(char(10),hire_da te,101)))


  3. #3
    Colin Y Guest

    Datetime field conversion (reply)

    Try this one:
    left(getdate(), 11)



    ------------
    Irene at 8/8/00 12:03:23 PM

    Hello, I would appreciate any suggestions
    I&#39;ve got a datetime field that I&#39;d like to store as just the date without the time component, but still to keep it defined as a datetime field. I ran this update statement but this conversion isn&#39;t working. Conversion to char gives me what I want but I need to keep the field as a date datatype if possible.
    Thanks

    update
    <table>
    set
    <column>=convert(datetime,convert(char(10),hire_da te,101)))


  4. #4
    Fred Guest

    Datetime field conversion (reply)

    Hi,
    This should work.

    convert(char(8), getdate(),1)

    If you convert this value back to date,
    you will see that the time is set to all zeros.

    fred.

    ------------
    Colin Y at 8/15/00 7:00:46 PM

    Try this one:
    left(getdate(), 11)



    ------------
    Irene at 8/8/00 12:03:23 PM

    Hello, I would appreciate any suggestions
    I&#39;ve got a datetime field that I&#39;d like to store as just the date without the time component, but still to keep it defined as a datetime field. I ran this update statement but this conversion isn&#39;t working. Conversion to char gives me what I want but I need to keep the field as a date datatype if possible.
    Thanks

    update
    <table>
    set
    <column>=convert(datetime,convert(char(10),hire_da te,101)))


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •