Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Any problme with this datediff statement?

Author  Topic 

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2010-06-01 : 22:04:26
Hi.I want to get the difference in a future date with the current date +1.
The statement is
SELECT DATEDIFF(day,convert(nvarchar,getdate(), 113)
,convert(nvarchar, (select datec from doctors where username = 'user1'),113))+1;

datec is of type datetime.
It checks out ok.My consideration is if i would have any problems?The collation is Latin Ansi on the db and greek Ansi on the table.
Is this ok, or do i need to fix something?The datec is automatically entered by using: Insert into doctors ..... Values(convert(nvarchar, getdate(), 113))

sapator
Constraint Violating Yak Guru

462 Posts

Posted - 2010-06-01 : 23:02:51
Since we are in this let me also input the code i have to add + number of dates to current date.
Is this ok?
update col1 set datec = (convert(nvarchar,(SELECT  convert(nvarchar,DATEADD(day,@Dayss
,convert(nvarchar,getdate(), 113)),113))))
Where username=lower(@ausername)
Go to Top of Page
   

- Advertisement -