Sqlserver error of date difference
-
hi; i want to write a sql query of different between two dates. ..................................................... DECLARE @mindays DATETIME DECLARE @today DATETIME SET @mindays =select min(daily_date) from r_dailymaterial_entry) SET @today = getdate() SELECT DATEDIFF(DAY, @mindays, @today) AS [DateDifference] ..................................................... i gets a error.. Server: Msg 156, Level 15, State 1, Line 4 Incorrect syntax near the keyword 'select'. please help me...
-
hi; i want to write a sql query of different between two dates. ..................................................... DECLARE @mindays DATETIME DECLARE @today DATETIME SET @mindays =select min(daily_date) from r_dailymaterial_entry) SET @today = getdate() SELECT DATEDIFF(DAY, @mindays, @today) AS [DateDifference] ..................................................... i gets a error.. Server: Msg 156, Level 15, State 1, Line 4 Incorrect syntax near the keyword 'select'. please help me...
snehasish wrote:
SET @mindays =select min(daily_date) from r_dailymaterial_entry)
Try the following. There was an extra parenthesis in the end and when you use select, you don't use set command in the start:
select @mindays = min(daily_date) from r_dailymaterial_entry
The need to optimize rises from a bad design. My articles[^]
-
snehasish wrote:
SET @mindays =select min(daily_date) from r_dailymaterial_entry)
Try the following. There was an extra parenthesis in the end and when you use select, you don't use set command in the start:
select @mindays = min(daily_date) from r_dailymaterial_entry
The need to optimize rises from a bad design. My articles[^]
hi Mika Wendelius, Many thanks to you for giving this solution.It works fine. Thanks once again. snehasish
-
hi Mika Wendelius, Many thanks to you for giving this solution.It works fine. Thanks once again. snehasish