January 4, 2012 at 6:40 am
hi
i'm sure this has been posted before but i'm not sure how to ask the questions so new topic...
i want to run a query for dec sales figures. so something like...
MyMonth = month(getdate()) -1
OR
datediff(mm, MyDate, Getdate()) Between 1 and 1
neither seem to want to work for me though. Is there anything i can do to handle this without writing a function?
thanks.
January 4, 2012 at 6:47 am
January 4, 2012 at 7:04 am
thanks
however, i need it to be dynamic so it runs on the first of every month. it's only an issue when its a new year.
January 4, 2012 at 7:13 am
So,
Declare @FirstMnth datetime
Select @FirstMnth = dateadd(mm,datediff(mm,0,getdate()),0)
Select Id
where DateCol >=@FirstMnth and DateCol < dateadd(mm,1,@Firstmnth)
BTW this is good reading : http://www.karaszi.com/SQLServer/info_datetime.asp
January 6, 2012 at 4:28 am
this works perfectly thanks
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply