Results 1 to 4 of 4

Thread: Help on Dates

  1. #1
    Join Date
    Nov 2002

    Unanswered: Help on Dates

    I'm new to SQL server...
    I'm trying to create a date (only) with no time.
    I'm importing the data from navchar to datetime and getting the time stamp. How do I configure the table to show only the date part?
    I did not see a date datatype....


  2. #2
    Join Date
    Feb 2002
    That creature does not exist. You will have to use the convert function using a style - look at sql server books online under 'Cast and Convert'.
    The time value stored when no time is provided is midnight - so you would have a date followed by 00:00:00.000. You might also consider smalldatetime.

    For example, using northwind's orders table:

    select convert(varchar(10), orderdate,101) from orders

  3. #3
    Join Date
    Nov 2002
    If my date field is indexed (2-3 million rows), then will the request read all records before converting and selecting?

  4. #4
    Join Date
    Dec 2002
    Czech Republic
    --replace "origDateTime" with our datetime value/column

    _ You can use datetime column with check constraint
    ( "origDateTime"=convert(datetime,convert(int,"origD ateTime")) )
    to ensure that there is no time saved, in the future you could need
    time, so you only remove this constraint. Linking to date analysis
    table will be done by indexed computed column on table level
    ( "compOnlyDate" AS convert(int,"origDateTime") )
    to get additional precomputed information about date
    (year,month,day in week,season,...) faster.
    _ If you NEVER use time, consider using only int
    or smallint ( convert(int,getdate())-30000 ),
    but be prepared on problems with user reports and applications.

Posting Permissions

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