Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Date

Status
Not open for further replies.
Jul 6, 2010
5
US
I have a date: 2010-07-01

How can I get it to print as July 2010?

Any help would be greatly appreciated.

Thanks!!
 
Code:
SELECT DATENAME(month, YourDate)+' '+CAST(YEAR(YourDate) as CHAR(4))
FROM YourTable

But I prefer to do this in my frontend.

Borislav Borissov
VFP9 SP2, SQL Server 2000,2005 & 2008.
 
My left join is not working. Can you tell me what is wrong and why I am getting the error msgs below?

error msg:
Msg 4104, Level 16, State 1, Line 23
The multi-part identifier "B.VndNbr" could not be bound.
Msg 4104, Level 16, State 1, Line 21
The multi-part identifier "B.VndNbr" could not be bound.
Msg 4104, Level 16, State 1, Line 21
The multi-part identifier "B.dup_grpid" could not be bound.

Code:
SELECT A.[VndNbr]
,Max(A.[VndName]) As VndName
,Min(A.[InvDt]) As InvDt_Min
,Max(A.[InvDt]) As InvDt_Max
,Sum(A.[AbsGrsInvAmt]) As AbsGrsInvAmt_Sum
,SUM( CASE SIGN(A.NetInvAmt)
WHEN 1 THEN A.NetInvAmt ELSE 0 END ) AS NetInvAmt_Pos,
SUM( CASE SIGN(A.NetInvAmt)
WHEN -1 THEN A.NetInvAmt ELSE 0 END ) AS NetInvAmt_Neg
,Min(A.[ChkDt]) ChkDt_Min
,Max(A.[ChkDt]) ChkDt_Max
-- ,[CliYer]
-- ,[PRGREFNBR]
-- ,[dup_grpid]
,B.Tot_Grps
,COUNT(*) As Tot_Recs
--INTO dbo.Xas_dupK_lst
FROM [KROGER_2010_AP].[dbo].[Xas_dupK] A
LEFT JOIN (Select B.VndNbr, Count(B.dup_grpid) as Tot_Grps
From [KROGER_2010_AP].[dbo].[Xas_dupK]
Group by B.VndNbr ) B
ON A.VndNbr = B.VndNbr
GROUP BY A.VndNbr
 
This part

Code:
(Select B.VndNbr, Count(B.dup_grpid) as Tot_Grps   
             From [KROGER_2010_AP].[dbo].[Xas_dupK] 
             Group by B.VndNbr )

uses b as alias for fields but doesn't give the table an alias.

Since it's a single table, you can remove b. from that derived table.


PluralSight Learning Library
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top