Professional Web Applications Themes

Date data type - Microsoft SQL / MS SQL Server

When a date is stored in a db, it is represented with date/time. How can I get just the date to be stored with no time? TIA Jim...

  1. #1

    Default Date data type

    When a date is stored in a db, it is represented with date/time. How can I
    get just the date to be stored with no time?
    TIA
    Jim


    James Guest

  2. #2

    Default Re: Date data type

    Thanks for the code. But this gets me the system date, I need the data from
    my date field. Can this still work?
    TIA
    Jim

    "Dinesh.T.K" <mail.tkdinesh.com> wrote in message
    news:#phx.gbl... [/ref]

    >
    >[/ref]


    James Guest

  3. #3

    Default Re: Date data type

    James,

    Sure.See this example

    CREATE TABLE dtealone
    (
    dte DATETIME
    )
    GO
    INSERT dtealone VALUES('05/05/2003 10:10:10')
    INSERT dtealone VALUES('05/05/2003')
    GO
    SELECT CONVERT(VARCHAR,dte,112)
    FROM dbo.dtealone

    ------------------------------
    20030505
    20030505


    --
    Dinesh.
    SQL Server FAQ at
    http://www.tkdinesh.com

    "James Rasmussen" <org> wrote in message
    news:eKck%phx.gbl... 
    from [/ref][/ref]
    can 
    > >
    > >[/ref]
    >
    >[/ref]


    Dinesh.T.K Guest

  4. #4

    Default Re: Date data type

    You can't if you want to hold it in a DATETIME / SMALLDATETIME datatype.
    If you enter a Date with no time then SQL Server will append midnight for
    you
    If you enter a time and no date then SQL Server will append 1/1/1900 for
    you.

    To view only the relevant parts you can look at CONVERT()

    --


    Allan Mitchell (Microsoft SQL Server MVP)
    MCSE,MCDBA
    www.SQLDTS.com
    I support PASS - the definitive, global community
    for SQL Server professionals - http://www.sqlpass.org
    Allan Guest

  5. #5

    Default Re: Date data type

    Thanks for the assistance. Now how do I format this to look like mm/dd/yyyy
    from its current format yyyymmdd?

    Thanks again
    Jim
    "Aaron Bertrand - MVP" <com> wrote in message
    news:phx.gbl... 
    > from [/ref][/ref]
    design.You [/ref][/ref]
    while [/ref]
    > can 
    > >
    > >[/ref]
    >
    >[/ref]


    James Guest

  6. #6

    Default Re: Date data type

    > Thanks for the assistance. Now how do I format this to look like
    mm/dd/yyyy 

    SELECT CONVERT(CHAR(10), date_column_name_not_specified, 101)
    FROM table_name_not_specified

    http://www.aspfaq.com/2460
    http://www.aspfaq.com/2464


    Aaron Guest

Similar Threads

  1. Display of date data type not correct
    By manhattanmediaworks in forum Coldfusion - Getting Started
    Replies: 2
    Last Post: May 21st, 03:16 AM
  2. Converting from data type varchar to data type money
    By schaudry in forum Coldfusion - Advanced Techniques
    Replies: 6
    Last Post: June 10th, 11:01 PM
  3. Converting data type varchar to data type money
    By schaudry in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: June 10th, 07:22 PM
  4. Replies: 3
    Last Post: October 18th, 06:56 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139