May 29, 2013 at 4:30 pm
Hi,
Am trying to give dynamic date to SP that would be first of every month. 5/01/2013 for this month can any one help me with the sql expression? i was trying with this but it is not applicable for other months.
declare
@date date
select
@date=CAST(MONTH(GETDATE()) AS VARCHAR(2))+'/'+CAST('01' AS varchar(3))
+
'/'+CAST(YEAR(GETDATE()) AS VARCHAR(4))
print @date
Thanks,
May 29, 2013 at 4:36 pm
shrsan (5/29/2013)
Hi,Am trying to give dynamic date to SP that would be first of every month. 5/01/2013 for this month can any one help me with the sql expression? i was trying with this but it is not applicable for other months.
declare
@date date
select
@date=CAST(MONTH(GETDATE()) AS VARCHAR(2))+'/'+CAST('01' AS varchar(3))
+
'/'+CAST(YEAR(GETDATE()) AS VARCHAR(4))
print @date
Thanks,
select cast(dateadd(month, datediff(month, 0, getdate()), 0) as date)
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply