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
 General SQL Server Forums
 New to SQL Server Programming
 Declare @Actdate

Author  Topic 

excelenvironment
Starting Member

2 Posts

Posted - 2013-03-10 : 19:55:30
Hi! I am new!
I am trying to figure out how I would change the bellow declare to get data from the 1st of March to the 31st of March 10, 2013. Does my question make sense?

Declare @Actdate varchar(20)
Set @Actdate = (Select DATEPART(yyyy, DATEADD(DD,-1,getdate()))*10000 + DATEPART(mm, DATEADD(DD,-1,getdate()))*100 + DATEPART(dd, DATEADD(DD,-1,getdate())))

excelenvironment
Starting Member

2 Posts

Posted - 2013-03-10 : 20:19:29
*Date range 1st of March to 31st of March
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2013-03-10 : 20:29:06
Your question doesn't make any sense, but I assume you want the beginning and ending of the current month?
declare @date date = getdate()
select DATEADD(month,datediff(month,0,getdate()),0)
,DATEADD(month,datediff(month,-1,getdate()),-1)

Is Actdate really a varchar or a date?

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -