Do I need DATEPART or similar

  • I have a function that uses the following statement in it

    SELECT     src_terrier.Areacode, src_terrier.siteref, src_terrier.estatename, src_terrier.Securitised, src_terrier.unitref, src_terrier.unittype,

                          src_terrier.unittype_count, src_terrier.tenantname, src_terrier.tenantstatus, src_terrier.tenantstatus_count, src_terrier.unitstatus,

                          src_terrier.unitstatus_count, src_terrier.floortotal, src_terrier.floortotocc, src_terrier.initialvacarea, src_terrier.initialvacnet, src_terrier.TotalRent,

                          src_terrier.NetRent, src_terrier.FinalRtLsincSC, src_terrier.ErvTot, src_terrier.tenancyterm, src_terrier.landact, src_terrier.datadate,

                          src_div_mgr.div_mgr, src_portfolio_mgr.portfolio_mgr, src_centre_list.propcat, src_tbl_rental.budgeted_net_rent,

                          src_tbl_rental.budgeted_occupancy

    FROM         src_terrier INNER JOIN

                          src_centre_list ON src_terrier.siteref = src_centre_list.Site_Ref AND src_terrier.Areacode = src_centre_list.Division INNER JOIN

                          src_div_mgr ON src_centre_list.Division = src_div_mgr.division INNER JOIN

                          src_portfolio_mgr ON src_centre_list.Portfolio_no = src_portfolio_mgr.portfolio_no LEFT OUTER JOIN

                          src_tbl_rental ON src_terrier.siteref = src_tbl_rental.site_ref

    WHERE   (src_terrier.datadate = @dt_src_date) AND

        (src_terrier.Areacode = @chr_div) AND

        (src_centre_list.Portfolio_no = @vch_portfolio_no) AND

        (src_centre_list.propcat = @vch_prop_cat) AND

        (src_tbl_rental.site_ref = src_terrier.siteref)

    The problem I have is that the 'src_terrier.datadate' is passed through as mm/dd/yyyy (which I do actually want to change to dd/mm/yyyy as that is how the data is stored) however, the src_date within the table src_tbl_rental is only set to 01/mm/yyyy. When I put an inner join on the date element it obviously does not find it as the sample data I am using is as follows

    src_terrier = 28/04/2006 and src_tbl_rental is 01/04/2006. Therefore if I pass the same parameter value through the dates are not the same and I get no data at all.

    How can I specify that for the purposes of the src_tbl_rental element of the select query, that I only want it to match the mm/yyyy part of the src_date.

    Therefore if some passes in

    28/04.2006 it will get the records from the terrier table that match that date, and only the records from rental that match the 04/2006 part of the date.

    Anybody confused by that , cause I am!

    Regards

  • Admin, please delete this post, I put it in the wrong section

    Apologies and Regards

     

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply