Viewing 15 posts - 781 through 795 (of 4,080 total)
There's a function for what you want: CONVERT()
select convert(varchar(6),convert(date,'01 Jan 1980'),12)
select convert(varchar(6),convert(date,'01 Jan 2000'),12)
The inner CONVERT function turns your string into a DATE character type. The...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
November 9, 2012 at 12:30 am
Hey, does anyone realize that in 8-9 days, The Thread will have been running strong for 4 consecutive years now?
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
November 9, 2012 at 12:14 am
Just arrived in Seattle. No chest pains, no shortness of breath. So far so good. 😛
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
November 4, 2012 at 9:22 pm
Feckless
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
November 4, 2012 at 9:20 pm
I've come to use CTE's rather than subqueries, as in the last example, simply because it is easier for me to read from the top down than from inside out.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
November 4, 2012 at 9:19 pm
Important to remember:
When someone says to use a certain technique because it is better/faster/more economical, make it a point to understand WHY. Blind faith...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 30, 2012 at 10:44 am
Cheryl McLaughlin-385812 (10/11/2012)
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 29, 2012 at 4:06 pm
I know, Sean. And I can't understand why that isn't it. It would be nice if the OP came back and told us...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 29, 2012 at 4:04 pm
Another solution is dynamic SQL. Write the query to return all rows, and then insert your TOP () and ORDER BY as needed.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 29, 2012 at 12:58 pm
Is there a reason why you can't just create a table with an identity column and add all your unique value pairs to it? Then you could simply...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 29, 2012 at 12:12 pm
Or did you mean to do something like this?
declare @datetimes table (ID int identity(1,1), date1 datetime, date2 datetime)
insert into @datetimes
select '11/03/2011','12/01/2012'
union all
select '11/03/2011','10/01/2011'
select MAX(case when Date1 >= Date2 then date1...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 26, 2012 at 9:25 am
You originally were talking about four dates, so that's how we wrote the functions.
Inline table valued functions can be implemented with a CROSS APPLY, like so.
declare @datetimes...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 26, 2012 at 9:06 am
My money is on Cadavre's solution.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 26, 2012 at 8:20 am
I feel compelled to post a warning against using such a technique on tables with production-scale volumes. It can lead to poor execution plans. ...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 25, 2012 at 2:32 pm
When considering datatypes, its important to remember that smaller is usually better. Using a numeric (2,0) datatype requires 5 bytes to store. Using an INT...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
October 25, 2012 at 12:27 pm
Viewing 15 posts - 781 through 795 (of 4,080 total)