Prev: SQL Server 2008 - user wants to directly backup database to his desktop
Next: How best to find out who did what when
From: Muhammad Bilal on 13 May 2010 10:52 Hi. I want to set gatdate() as a default to a column of datatype datetime in sql server 2000 but in format DD/MM/YYYY. I have used (RIGHT('0' + RTRIM(DAY(GETDATE())), 2) + '/' + RIGHT('0' + RTRIM(MONTH(GETDATE())), 2) + '/' + RTRIM(YEAR(GETDATE()))) but this is not working properly. Regards, Muhammad Bilal
From: Gert-Jan Strik on 13 May 2010 11:21 If the column has data type datetime, then there is no need to convert the date to char. You can use something like this: DATEADD(day,DATEDIFF(day,0,CURRENT_TIMESTAMP),0) -- Gert-Jan Muhammad Bilal wrote: > > Hi. > > I want to set gatdate() as a default to a column of datatype datetime in sql > server 2000 but in format DD/MM/YYYY. > > I have used (RIGHT('0' + RTRIM(DAY(GETDATE())), 2) + '/' + RIGHT('0' + > RTRIM(MONTH(GETDATE())), 2) + '/' + RTRIM(YEAR(GETDATE()))) > but this is not working properly. > > Regards, > Muhammad Bilal
From: jgurgul on 13 May 2010 11:58
Hi, I would advise using date or datetime and doing the formating in the front end as strongly typed data is easy to work with. SELECT CONVERT(VARCHAR(8),GETDATE(),03) "Muhammad Bilal" wrote: > Hi. > > I want to set gatdate() as a default to a column of datatype datetime in sql > server 2000 but in format DD/MM/YYYY. > > I have used (RIGHT('0' + RTRIM(DAY(GETDATE())), 2) + '/' + RIGHT('0' + > RTRIM(MONTH(GETDATE())), 2) + '/' + RTRIM(YEAR(GETDATE()))) > but this is not working properly. > > > Regards, > Muhammad Bilal > |