Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    54

    Unanswered: Default Date Value (today)

    I have migrated from Access to SQL Server.
    In Access I have default date value of today's date.

    In SQL Server, it is empty (after migration).
    What is the corresponding syntax (value) to default to
    the current Date & Time in a DATETIME Field (using Design Table) ?

    Thanks you.

    Also, what is the difference between DATETIME and SMALLDATETIME
    fields ?

    Pierre.
    Pierre (Pl-Arts)

  2. #2
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    110

    Re: Default Date Value (today)

    Hey there,

    When creating your table add a default constraint to your column, something like...

    create table a_tbl (
    col1 int not null,
    col2 datetime constraint constr_1 default(getdate())
    )

    Or if you were creating the table using the table disign GUI, the default value should be getdate().

    As for the difference between datetiem and smalldatetime, there is plenty of info in BOL. But basically smalldatetime is rounded to the nearest mintue, where as datetime is detailed to the fraction of a secound.

    Hope this helps.

    Originally posted by Plarde
    I have migrated from Access to SQL Server.
    In Access I have default date value of today's date.

    In SQL Server, it is empty (after migration).
    What is the corresponding syntax (value) to default to
    the current Date & Time in a DATETIME Field (using Design Table) ?

    Thanks you.

    Also, what is the difference between DATETIME and SMALLDATETIME
    fields ?

    Pierre.

  3. #3
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    As referred books online is the best bet to startwith the differences, syntax information and other examples which will give strength to the current knowledge in SQL server and ofcourse this forum is available to help you out in any consequences.

    Good luck.
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

Posting Permissions

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