Can any pls check the query i had write for the below statment as i am not getting the desired result as per statement
Create proc sp1
as
Begin
DECLARE
@date DateTime
SET
@date =GetDate()
Insert into tbl_test1
( order_date , Order_period_from )
Values
( @Date , Case 0 select max(Order_date) else current year )
end
Select last (max) ORDER_DATE for the market and add one day to it. If there is no last date available for the market then insert 1st Jan <Current year> as the ORDER_PERIOD_FROM date
lalitkumar
Member
22 Points
70 Posts
how to use DateFunction in SP
Nov 17, 2012 09:47 AM|LINK
Can any pls check the query i had write for the below statment as i am not getting the desired result as per statement
Create proc sp1
as
Begin
DECLARE @date DateTime
SET @date = GetDate()
Insert into tbl_test1
( order_date , Order_period_from )
Values
( @Date , Case 0 select max(Order_date) else current year )
end
Select last (max) ORDER_DATE for the market and add one day to it. If there is no last date available for the market then insert 1st Jan <Current year> as the ORDER_PERIOD_FROM date
spapim
Contributor
2464 Points
372 Posts
Re: how to use DateFunction in SP
Nov 17, 2012 12:00 PM|LINK
Try:
( @Date , COALESCE( DATEADD(day, 1, select max(Order_date) from tbl_test1), CAST( CAST(YEAR(GETDATE()) AS VARCHAR(5)) + '/01/01' AS DATE) )Hope this helps.
www.imobiliariasemsuzano.com.br