all groups > sql server connect > october 2004 >
You're in the

sql server connect

group:

Dumb Date Format Question


Re: Dumb Date Format Question Kalen Delaney
10/29/2004 3:34:36 PM
sql server connect:
Hi Matthew

Ask whatever you like here, just don't call anything a dumb question. That
way, you give people who have only been using the product a bit longer than
you a chance to answer questions and feel like they have learned something.
But nobody wants to feel like they can only answer DUMB questions. ;-)

& is the bitwise 'AND' operator, and its operands must be integers. Please
read about bit operations in the Books Online.

My guess is that you want to concatenate strings. In TSQL we use '+' for
concatenation.

But, it still won't work because datepart returns a numeric value. Try using
datename. Or converting to character before you concatenate.

--
HTH
----------------
Kalen Delaney
SQL Server MVP
www.SolidQualityLearning.com


[quoted text, click to view]

Dumb Date Format Question Matthew
10/29/2004 5:12:24 PM
I want the following query to result in "2004/10".

SELECT DATEPART(yyyy, datein) & '/' & DATEPART(mm, datein) AS theDate
From myTable

However, I get the error:
Syntax error converting the varchar value '/' to a column of data type int.

Is there a better way to do this?

Also, I realize I may be asking this in the wrong forum. Is there a place
for MSSQL newbies to ask their dumb questions?

Thank you!

Matthew

Re: Dumb Date Format Question Matthew
10/30/2004 8:59:34 PM
[quoted text, click to view]

Sorry about that. I'll be more careful in the future.

[quoted text, click to view]

Yup, that's right.

[quoted text, click to view]

OK, I'll give that a try.

Thank you!

Matthew

AddThis Social Bookmark Button