Home All Groups Group Topic Archive Search About

set datefield default to a specific date

Author
4 Feb 2006 11:23 PM
GTN170777
Hi all,

I would be really grateful for your assistance with this. I need to set the
default value od a date field to a specific date - in this instance the date
would be 01/06/2006.
Is there any code that will do this?
Thanks in advance

Gareth

Author
4 Feb 2006 11:44 PM
Dave Frommer
CREATE TABLE Test
(
MyDate DateTime CONSTRAINT TestMyDateDefault DEFAULT '2006-01-06'
)

Show quote
"GTN170777" <GTN170***@discussions.microsoft.com> wrote in message
news:80B837B3-C233-48D3-8713-DE8EBEB66116@microsoft.com...
> Hi all,
>
> I would be really grateful for your assistance with this. I need to set
> the
> default value od a date field to a specific date - in this instance the
> date
> would be 01/06/2006.
> Is there any code that will do this?
> Thanks in advance
>
> Gareth
Author
5 Feb 2006 12:17 AM
GTN170777
Is there any other way of doing this? maybe by just setting the default
value? i'm new to MS SQL and using EMS SQL Manager to edit my database

Show quote
"Dave Frommer" wrote:

> CREATE TABLE Test
> (
>  MyDate DateTime CONSTRAINT TestMyDateDefault DEFAULT '2006-01-06'
> )
>
> "GTN170777" <GTN170***@discussions.microsoft.com> wrote in message
> news:80B837B3-C233-48D3-8713-DE8EBEB66116@microsoft.com...
> > Hi all,
> >
> > I would be really grateful for your assistance with this. I need to set
> > the
> > default value od a date field to a specific date - in this instance the
> > date
> > would be 01/06/2006.
> > Is there any code that will do this?
> > Thanks in advance
> >
> > Gareth
>
>
>
Author
5 Feb 2006 2:18 AM
Roger Wolter[MSFT]
This IS the way to set the default value.  If you are looking for a way to
have your tool do this for you, you will have to talk to the tool vendor.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Show quote
"GTN170777" <GTN170***@discussions.microsoft.com> wrote in message
news:C09559D5-0D2F-47FB-80F9-2CF581A8296C@microsoft.com...
> Is there any other way of doing this? maybe by just setting the default
> value? i'm new to MS SQL and using EMS SQL Manager to edit my database
>
> "Dave Frommer" wrote:
>
>> CREATE TABLE Test
>> (
>>  MyDate DateTime CONSTRAINT TestMyDateDefault DEFAULT '2006-01-06'
>> )
>>
>> "GTN170777" <GTN170***@discussions.microsoft.com> wrote in message
>> news:80B837B3-C233-48D3-8713-DE8EBEB66116@microsoft.com...
>> > Hi all,
>> >
>> > I would be really grateful for your assistance with this. I need to set
>> > the
>> > default value od a date field to a specific date - in this instance the
>> > date
>> > would be 01/06/2006.
>> > Is there any code that will do this?
>> > Thanks in advance
>> >
>> > Gareth
>>
>>
>>
Author
5 Feb 2006 6:15 AM
Steve Kass
Dave,

Your default means January 6, 2006 in some countries, and June 1, 2006
in others.  If you want January 6 for all SQL Server installations, write
DEFAULT '20060106'

Steve Kass
Drew University

Show quote
"Dave Frommer" <anti@spam.com> wrote in message
news:OWUcPTeKGHA.720@TK2MSFTNGP14.phx.gbl...
> CREATE TABLE Test
> (
> MyDate DateTime CONSTRAINT TestMyDateDefault DEFAULT '2006-01-06'
> )
>
> "GTN170777" <GTN170***@discussions.microsoft.com> wrote in message
> news:80B837B3-C233-48D3-8713-DE8EBEB66116@microsoft.com...
>> Hi all,
>>
>> I would be really grateful for your assistance with this. I need to set
>> the
>> default value od a date field to a specific date - in this instance the
>> date
>> would be 01/06/2006.
>> Is there any code that will do this?
>> Thanks in advance
>>
>> Gareth
>
>
Author
5 Feb 2006 12:35 PM
GTN170777
Thanks guys, i've set the default value to '20060601' as for some reason the
tool i'm using takes the default as 'yyyymmdd'
Thanks for your help

Show quote
"Steve Kass" wrote:

> Dave,
>
> Your default means January 6, 2006 in some countries, and June 1, 2006
> in others.  If you want January 6 for all SQL Server installations, write
> DEFAULT '20060106'
>
> Steve Kass
> Drew University
>
> "Dave Frommer" <anti@spam.com> wrote in message
> news:OWUcPTeKGHA.720@TK2MSFTNGP14.phx.gbl...
> > CREATE TABLE Test
> > (
> > MyDate DateTime CONSTRAINT TestMyDateDefault DEFAULT '2006-01-06'
> > )
> >
> > "GTN170777" <GTN170***@discussions.microsoft.com> wrote in message
> > news:80B837B3-C233-48D3-8713-DE8EBEB66116@microsoft.com...
> >> Hi all,
> >>
> >> I would be really grateful for your assistance with this. I need to set
> >> the
> >> default value od a date field to a specific date - in this instance the
> >> date
> >> would be 01/06/2006.
> >> Is there any code that will do this?
> >> Thanks in advance
> >>
> >> Gareth
> >
> >
>
>
>

AddThis Social Bookmark Button