February 13, 2008 at 10:15 am
Is there a way that I can take two date variables and combine them into a single column?
eg
INPUT:
PeriodStartDate = '02/01/2008'
PeriodEndDate='02/15/2008'
OUTPUT:
EffectiveDate =' 02/01 - 02/15'
Thanks,
Art
Database Analyst
Tastefully Simple, Inc.
alorenzini@tastefullysimple.com
" Some days, it's not even worth chewing through the restraints!
February 13, 2008 at 10:28 am
Cast them to char first with a format you like, then chop off what you don't want:
left(convert(char,PeriodstartDate,101),5)+' - '+left(convert(char,PeriodEndDate,101),5)
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
February 13, 2008 at 10:30 am
You want one character field, correct? Here you go:
SELECT CONVERT(CHAR(5), GETDATE()-7, 110) + ' - ' + CONVERT(CHAR(5), GETDATE(), 110)
Just replace the "GETDATE()" part with the dates you want to use.
Dan
February 13, 2008 at 12:09 pm
This works great,thanks.
Thanks,
Art
Database Analyst
Tastefully Simple, Inc.
alorenzini@tastefullysimple.com
" Some days, it's not even worth chewing through the restraints!
February 13, 2008 at 12:52 pm
What are you trying to accomplish? Storing dates in any other form than a datetime column causes problems down the road.
February 13, 2008 at 1:28 pm
I need to display the dates displayed in this format but they will not used for calculations.
Thanks,
Art
Database Analyst
Tastefully Simple, Inc.
alorenzini@tastefullysimple.com
" Some days, it's not even worth chewing through the restraints!
February 13, 2008 at 1:30 pm
Ah. So you are only going to use this in a SELECT to diplay the values. I had thought that you were going to create a new column to store this value.
February 13, 2008 at 1:36 pm
Correct,it for a report.
Thanks,
Art
Database Analyst
Tastefully Simple, Inc.
alorenzini@tastefullysimple.com
" Some days, it's not even worth chewing through the restraints!
February 13, 2008 at 6:19 pm
Hi,
As per the database design policy you should not concatinate the fields. May be right now you dont have any requiremnts to update these values but later if there is one then its difficult to implement. So at the database level store it in two columns while diplaying it concatinate the fields.
Thanks -- Vj
February 13, 2008 at 9:27 pm
Just curious, Art... haven't seen it before... what does a "Database Analyst" do? In other words, what's the job description for a "Database Analyst"?
--Jeff Moden
Change is inevitable... Change for the better is not.
February 14, 2008 at 8:34 am
I think it is used as a general term Jeff. In my previous job, I was an application developer for about 6 years. I showed some savvy with working with our UNIX servers so they made me the UNIX administrator on top of my existing duties. Since our UNIX servers housed Oracle and Progress DBs, I was given responsibility over them as well. And finally, they gave me the SQL Server windows servers and changed my title to Programmer / Database Analyst. I was working in the roll of production DBA, UNIX administrator and part time programmer.
I was hired on in my current job as a Senior DBA focusing solely on SQL Server development. The company I worked for changed their job pay grades and my title got changed to Lead Database Analyst. Our company has since been bought out and I think I will be getting yet another title change this month to match up with the new companies job description and pay grades. I guess I don't really care what they call me as long as the checks still cash and I'm getting good yearly increases.
PS....I know this question was directed at someone else, but I thought I'd chime in 😀
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply