March 6, 2014 at 10:08 am
Hello,
Can someone please help me
I am trying to get the following information can't get it,I need to get from
field is MAX(CONV_DATE) AS MaxConv_Date
I need get max CONV_DATE which can't >then todays day and < then 30 days from today.
Thank you
March 6, 2014 at 10:15 am
Krasavita (3/6/2014)
Hello,Can someone please help me
I am trying to get the following information can't get it,I need to get from
field is MAX(CONV_DATE) AS MaxConv_Date
I need get max CONV_DATE which can't >then todays day and < then 30 days from today.
Thank you
WOW talk about not much information. As a shot in the dark maybe you should be using a WHERE clause?
WHERE CONV_DATE > dateadd(dd, datediff(dd, 0, getdate()), 0) --beginning of today
and CONV_DATE < dateadd(dd, datediff(dd, 0, getdate()), 30) --today plus 30
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
March 6, 2014 at 10:15 am
Just get your MAX as normal then add criteria to limit the range.
Please show what code you have so far.
March 6, 2014 at 10:26 am
by putting these code:
WHERE (CONV_DATE > DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0)) AND (CONV_DATE < DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 30))
I get error arifmetical overflow converting expression to data type to datetime
March 6, 2014 at 12:07 pm
Krasavita (3/6/2014)
by putting these code:WHERE (CONV_DATE > DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 0)) AND (CONV_DATE < DATEADD(dd, DATEDIFF(dd, 0, GETDATE()), 30))
I get error arifmetical overflow converting expression to data type to datetime
That is a pretty good indication that you don't have a datetime datatype. You really should store datetime information in a datetime column. I am guessing you are using either a varchar or an int column?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply