Please assist me to get the year, month, week to date to show like my example doeson the right below. What changes I can make to my query to get it to show as I need it to below.
DataSet:
SELECT DATEPART(YY,c.loandate) as YearLoan, DATEPART(MM,c.loandate) AS MonthLoan, DATEPART(WW,c.loandate) AS WeekLoan,a.SSN,A.[Borrower Firstname],a.[Borrower Email], a.[Home Phone], a.[cell phone], a.[marital status], a.[Date of Birth], a.[Current Street Address], a.city,a.[state],a.zip,a.Yearsatthisaddress, a.sex,a.ethnicity,a.race,a.isactive,b.MonthlyIncome,b.Bonuses,b.Commission,b.OtherIncome,b.[Rent or Own],b.Checking,b.Savings,b.RetirementFund,b.MutualFund,
c.[Purpose of Loan],c.LoanAmount,c.[Purchase Price],c.CreditCardAuthorization,c.[Number of Units],c.Refferal,c.[Co-Borrower SSN],c.loandate,
d.[Property Usage],d.[Property City],d.[Property State],d.[Property Zip],d.RealEstateAgentName,d.RealEstateAgentPhone,d.RealEstateAgentEmail
FROMdim_borrower a
LEFT OUTER JOINFact_Financial b
ONa.BorrowerID=b.borrowerid
LEFT OUTER JOINDim_Loan c
ONb.LoanID=c.Loan_ID
LEFT OUTER JOINDim_Property d
ONd.property_id=b.propertyid
whereDATEPART(YY,c.loandate) = DATEPART(YY,GETDATE())
ORDATEPART(MM,c.loandate) = DATEPART(MM,GETDATE())
ORDATEPART(WW,c.loandate) = DATEPART(WW,GETDATE())