Setting Field default to date portion of datetime

Setting Field default to date portion of datetime

Post by Greg Jense » Tue, 12 Jan 1999 04:00:00



I would like to have a field default of several tables in my database set to
the date portion of the getdate() function

I tried convert(getdate(),1) but I get a syntax error. I am using datetime
for the field type.

I am also using SQL Server 7.0 Desktop.

 
 
 

Setting Field default to date portion of datetime

Post by Alexander Tarasu » Tue, 12 Jan 1999 04:00:00


Just one more step

convert(datetime,convert(varchar,getdate(),1) )

--
Alexander Tarasul  MCSD
Certified Borland Delphi Developer

http://pages.ripco.com/~shleym

Answers on SQL Server questions at
http://pages.ripco.com/~shleym/sql_answers.htm
===========================================


>I would like to have a field default of several tables in my database set
to
>the date portion of the getdate() function

>I tried convert(getdate(),1) but I get a syntax error. I am using datetime
>for the field type.

>I am also using SQL Server 7.0 Desktop.


 
 
 

Setting Field default to date portion of datetime

Post by Craig Mees » Tue, 12 Jan 1999 04:00:00


The correct format for the convert function is:
    convert(char(10),getdate(),101)
char(10) converts to character datatype and 101 will format getdate() as
"01/11/1999"

Craig Meese
MCSD/MCT
Saturn Business Solutions


>I would like to have a field default of several tables in my database set
to
>the date portion of the getdate() function

>I tried convert(getdate(),1) but I get a syntax error. I am using datetime
>for the field type.

>I am also using SQL Server 7.0 Desktop.