# Conversion failed when converting date and/or time from character string.



## evelynblabla (21. Jun 2018)

Manchmal klappt die Abfrage manchmal nicht. Wie konvertiere ich das Datum richtig.
In meiner Datenbank werden die Datumsangaben "2018-06-02" gespeichert jedoch wählt der Nutzer auf der Benutzeroberfläche das Datumsformat 02.06.2018. Nun muss ich (im Quellcode markiert) die Daten konvertieren, damit die Abfrage durchgeführt werden kann.

```
public ArrayList<ArrayList<String>> doSQL(FilterModel filter) {
      String sAttr = "statisticView.hasEnd as HatEnde "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      String wAttr = ""; //$NON-NLS-1$
      String gAttr = "statisticView.hasEnd"; //$NON-NLS-1$

      //TODO neue Datenfelder auch abrufen
      // groupBy und Select
      if (filter.isGroupByCosts()) {
         sAttr = "statisticView.costs AS "+LanguageBundle.getString("DBAccess.FilterCosts")+", " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ? "statisticView.costs" : gAttr +", statisticView.costs" ; //$NON-NLS-1$ //$NON-NLS-2$
      }


      if (filter.isGroupByScore()) {
         sAttr = "statisticView.score AS "+LanguageBundle.getString("DBAccess.FilterBewertung")+", " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.score": gAttr + ", statisticView.score" ; //$NON-NLS-1$ //$NON-NLS-2$
      }




      if (filter.isGroupByContent()) {
         sAttr = "statisticView.description" +(en? "_en":"")+" AS '"+LanguageBundle.getString("DBAccess.FilterInhalt")+"', "+ sAttr;
         gAttr = gAttr.length() == 0 ? "statisticView.description"+ (en ? "_en" : "") : gAttr +", statisticView.description"+ (en ? "_en": "");
      }
      if (filter.isGroupByFunding()) {
         sAttr = "statisticView.fundingName" +(en? "_en":"" )+" AS '"+LanguageBundle.getString("DBAccess.FilterFoerderung")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ? "statisticView.fundingName"+ (en ? "_en" : "") : gAttr +", statisticView.fundingName"+ (en ? "_en" : "") ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByCostCenter()) {
         sAttr = "statisticView.costCenter AS '"+LanguageBundle.getString("DBAccess.FilterKostenstelle")+"', " + sAttr;
         gAttr = gAttr.length() == 0 ? "statisticView.costCenter" : gAttr +", statisticView.costCenter";
         //wAttr = wAttr + " AND (businessFieldName LIKE '%F&E%')";
      }
      if (filter.isGroupByBusinessField()) {
         sAttr = "statisticView.businessFieldName" +(en? "_en":"" )+" AS '"+LanguageBundle.getString("DBAccess.FilterGeschaeftsfeld")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ? "statisticView.businessFieldName"+ (en ? "_en" : "") : gAttr +", statisticView.businessFieldName"+ (en ? "_en" : "") ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByPerson()) {
         sAttr = "statisticView.contactPersonGanz AS '" + LanguageBundle.getString("DBAccess.FilterKontaktPerson")+"', "+ sAttr;
//       sAttr = "contactPersonForename AS " + LanguageBundle.getString("ContactPersonForename")+", "+ sAttr;
//       sAttr = "contactPersonTitle AS " + LanguageBundle.getString("ContactPersonTitle")+", "+ sAttr;

         gAttr = gAttr.length() == 0 ? "statisticView.contactPersonGanz" : gAttr +", statisticView.contactPersonGanz";
//       gAttr = gAttr.length() == 0 ? "contactPersonForename" : gAttr +", contactPersonForename";
//       gAttr = gAttr.length() == 0 ? "contactPersonName" : gAttr +", contactPersonName";
      }
      if (filter.isGroupByChair()) {
         sAttr = "statisticView.chair AS '"+LanguageBundle.getString("DBAccess.FilterLehrstuhl")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.chair": gAttr + ", statisticView.chair" ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByFaculty()) {
         sAttr = "statisticView.faculty AS '"+LanguageBundle.getString("DBAccess.FilterFakultaet")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.faculty": gAttr + ", statisticView.faculty" ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByLocation()) {
         sAttr = "statisticView.location AS '"+LanguageBundle.getString("DBAccess.FilterOrt")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.location": gAttr + ", statisticView.location" ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByNation()) {
         sAttr = "statisticView.Nation AS '"+LanguageBundle.getString("DBAccess.FilterLand")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.Nation": gAttr + ", statisticView.Nation" ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByInstitute()) {
         sAttr = "statisticView.instName AS '"+LanguageBundle.getString("DBAccess.FilterInstitution")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.instName": gAttr + ", statisticView.instName" ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByTypeOfInst()) {
         sAttr = "statisticView.typeOfInstName" +(en? "_en":"" )+" AS '"+LanguageBundle.getString("DBAccess.FilterArtDerInstitution")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.typeOfInstName"+ (en ? "_en" : ""): gAttr + ", statisticView.typeOfInstName"+ (en ? "_en" : "") ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByTitle()) {
         sAttr = "statisticView.title"+(en ? "_en" : "")+" AS '"+LanguageBundle.getString("DBAccess.FilterTitel")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.title"+(en ? "_en" : "") : gAttr + ", statisticView.title"+(en ? "_en" : ""); //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByDepartment()) {
         sAttr = "statisticView.department AS '"+LanguageBundle.getString("DBAccess.FilterAbteilung")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.department": gAttr + ", statisticView.department" ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByBrandCompany()) {
         sAttr = "statisticView.brandName"+ " AS '"+LanguageBundle.getString("DBAccess.FilterMarke")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.brandName" : gAttr + ", statisticView.brandName" ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByTopic()) {
         sAttr = "statisticView.topicName" +(en? "_en":"" )+" AS '"+LanguageBundle.getString("DBAccess.FilterThemenfeld")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.topicName"+ (en ? "_en" : ""): gAttr + ", statisticView.topicName"+ (en ? "_en" : "") ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByTypeOfCoop()) {
         sAttr = "statisticView.typeName" +(en? "_en":"" )+" AS '"+LanguageBundle.getString("DBAccess.FilterArtDerZusammenarbeit")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.typeName"+ (en ? "_en" : ""): gAttr + ", statisticView.typeName"+ (en ? "_en" : "") ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByStatus()) {
         sAttr = "statisticView.statusName" +(en? "_en":"" )+" AS '"+LanguageBundle.getString("DBAccess.FilterStatus")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.statusName"+ (en ? "_en" : ""): gAttr + ", statisticView.statusName"+ (en ? "_en" : "") ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByEndDate()) {
         sAttr = "statisticView.endDate AS '"+LanguageBundle.getString("DBAccess.FilterEnddatum")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.endDate": gAttr + ", statisticView.endDate" ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByStartDate()) {
         sAttr = "statisticView.startDate AS '"+LanguageBundle.getString("DBAccess.FilterStartdatum")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ?  "statisticView.startDate": gAttr + ", statisticView.startDate" ; //$NON-NLS-1$ //$NON-NLS-2$
      }
      if (filter.isGroupByID()) {
         sAttr = "statisticView.coopID AS '"+LanguageBundle.getString("DBAccess.FilterID")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         gAttr = gAttr.length() == 0 ? "statisticView.coopID" : gAttr +", statisticView.coopID" ; //$NON-NLS-1$ //$NON-NLS-2$
      }

      sAttr = "CoopView.lastChange AS '"+LanguageBundle.getString("DBAccess.FilterLetzteAenderung")+"', " + sAttr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      gAttr = gAttr.length() == 0 ? "CoopView.lastChange" : gAttr +", CoopView.lastChange" ; //$NON-NLS-1$ //$NON-NLS-2$

      //TEST
      System.out.println(sAttr);
      System.out.println(gAttr);

      //Mehrfachauswahl für: Abteilung, Fakultät, Lehrstuhl, Ort, Titel, Einrichtung, Inhalt

      [COLOR=#ff8000][B]SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$[/B][/COLOR]

      // Where
      if (filter.getBrandCompanyString().length>0) {
         wAttr = wAttr + " AND ((statisticView.brandName"+ (en ? "_en" : "")+" LIKE '%" + filter.getBrandCompanyString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getBrandCompanyString().length; ++i){
            wAttr = wAttr + " OR (statisticView.brandName"+ (en ? "_en" : "")+" LIKE '%" + filter.getBrandCompanyString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getChairString().length>0) {
         wAttr = wAttr + " AND ((statisticView.chair LIKE '%" + filter.getChairString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getChairString().length; ++i){
            wAttr = wAttr + " OR (statisticView.chair LIKE '%" + filter.getChairString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getTitleString().length>0) {
         wAttr = wAttr + " AND ((statisticView.title"+ (en ? "_en" : "")+" LIKE '%" + filter.getTitleString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getTitleString().length; ++i){
            wAttr = wAttr + " OR (statisticView.title"+ (en ? "_en" : "")+" LIKE '%" + filter.getTitleString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getDepartmentString().length>0) {
         wAttr = wAttr + " AND ((statisticView.department LIKE '%" + filter.getDepartmentString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getDepartmentString().length; ++i){
            wAttr = wAttr + " OR (statisticView.department LIKE '%" + filter.getDepartmentString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getDescriptionString().length>0) {
         wAttr = wAttr + " AND ((statisticView.description"+ (en ? "_en" : "")+" LIKE '%" + filter.getDescriptionString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getDescriptionString().length; ++i){
            wAttr = wAttr + " OR (statisticView.description"+ (en ? "_en" : "")+" LIKE '%" + filter.getDescriptionString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getStartStartDateDate().length>0) {
         wAttr = wAttr + " AND ((DATEDIFF (d,statisticView.startDate,'" + [B][COLOR=#ff8000]filter.getStartStartDateDate()[0].getFilter() + "'[/COLOR][/B]) <= 0)"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getStartStartDateDate().length; ++i){
            wAttr = wAttr + " OR ([COLOR=#ff8000][B]DATEDIFF (d,statisticView.startDate,'" + filter.getStartStartDateDate()[I].getFilter() + "') <= 0)";[/I][/B][/COLOR][I] //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getStartEndDateDate().length>0) {
         wAttr = wAttr + " AND ((DATEDIFF (d,[COLOR=#ff8000][B]statisticView.startDate,'" + filter.getStartEndDateDate()[0].getFilter() + "'[/B][/COLOR]) >= 0)"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getStartEndDateDate().length; ++i){
            wAttr = wAttr + " OR (DATEDIFF (d,s[COLOR=#ff8000][B]tatisticView.startDate,'" + filter.getStartEndDateDate()[I].getFilter() + "')[/I][/B][/COLOR][I] >= 0)"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getEndStartDateDate().length>0) {
         wAttr = wAttr + " AND ((DATEDIFF (d,statisticView.endDate,'" + filter.getEndStartDateDate()[0].getFilter() + "') <= 0)"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getEndStartDateDate().length; ++i){
            wAttr = wAttr + " OR (DATEDIFF (d,statisticView.endDate,'" + filter.getEndStartDateDate()[I].getFilter() + "') <= 0)"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getEndEndDateDate().length>0) {
         wAttr = wAttr + " AND ((DATEDIFF (d,statisticView.endDate,'" + filter.getEndEndDateDate()[0].getFilter() + "') >= 0)"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getEndEndDateDate().length; ++i){
            wAttr = wAttr + " OR (DATEDIFF (d,statisticView.endDate,'" + filter.getEndEndDateDate()[I].getFilter() + "') >= 0)"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getStatusString().length>0) {
         wAttr = wAttr + " AND ((statisticView.statusName"+ (en ? "_en" : "")+" LIKE '%" + filter.getStatusString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getStatusString().length; ++i){
            wAttr = wAttr + " OR (statisticView.statusName"+ (en ? "_en" : "")+" LIKE '%" + filter.getStatusString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getTopicString().length>0) {
         wAttr = wAttr + " AND ((statisticView.topicName"+ (en ? "_en" : "")+" LIKE '%" + filter.getTopicString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getTopicString().length; ++i){
            wAttr = wAttr + " OR (statisticView.topicName"+ (en ? "_en" : "")+" LIKE '%" + filter.getTopicString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getTypeOfCoopString().length>0) {
         wAttr = wAttr + " AND ((statisticView.typeName"+ (en ? "_en" : "")+" LIKE '%" + filter.getTypeOfCoopString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getTypeOfCoopString().length; ++i){
            wAttr = wAttr + " OR (statisticView.typeName"+ (en ? "_en" : "")+" LIKE '%" + filter.getTypeOfCoopString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getScoreString().length>0) {
         wAttr = wAttr + " AND ((statisticView.score = " + filter.getScoreString()[0].getFilter().substring(0, 1) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getScoreString().length; ++i){
            wAttr = wAttr + " OR (statisticView.score = " + filter.getScoreString()[I].getFilter().substring(0, 1) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getFacultyString().length>0) {
         wAttr = wAttr + " AND ((statisticView.faculty LIKE '%" + filter.getFacultyString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getFacultyString().length; ++i){
            wAttr = wAttr + " OR (statisticView.faculty LIKE '%" + filter.getFacultyString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getInstituteString().length>0) {
         wAttr = wAttr + " AND ((statisticView.instName LIKE '%" + filter.getInstituteString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getInstituteString().length; ++i){
            wAttr = wAttr + " OR (statisticView.instName LIKE '%" + filter.getInstituteString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getLocationString().length>0) {
         wAttr = wAttr + " AND ((statisticView.location LIKE '%" + filter.getLocationString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getLocationString().length; ++i){
            wAttr = wAttr + " OR (statisticView.location LIKE '%" + filter.getLocationString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getNationString().length>0) {
         wAttr = wAttr + " AND ((statisticView.nation LIKE '%" + filter.getNationString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getNationString().length; ++i){
            wAttr = wAttr + " OR (statisticView.nation LIKE '%" + filter.getNationString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getTypeOfInstString().length>0) {
         wAttr = wAttr + " AND ((statisticView.typeOfInstName LIKE '%" + filter.getTypeOfInstString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getTypeOfInstString().length; ++i){
            wAttr = wAttr + " OR (statisticView.typeOfInstName LIKE '%" + filter.getTypeOfInstString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getFundingString().length>0) {
         wAttr = wAttr + " AND ((statisticView.fundingName"+ (en ? "_en" : "")+" LIKE '%" + filter.getFundingString()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getFundingString().length; ++i){
            wAttr = wAttr + " OR (statisticView.fundingName"+ (en ? "_en" : "")+" LIKE '%" + filter.getFundingString()[I].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getHandlungsfeldString().length>0) {
         wAttr = wAttr + " AND ((statisticView.actionFieldName"+ (en ? "_en" : "")+" LIKE '" + filter.getHandlungsfeldString()[0].getFilter() + "')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getHandlungsfeldString().length; ++i){
            wAttr = wAttr + " OR ((statisticView.actionFieldName"+ (en ? "_en" : "")+" LIKE '" + filter.getHandlungsfeldString()[I].getFilter() + "')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getBusinessFieldString().length>0) {
         wAttr = wAttr + " AND ((statisticView.businessFieldName LIKE '" + filter.getBusinessFieldString()[0].getFilter() + "')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getBusinessFieldString().length; ++i){
            wAttr = wAttr + " OR (statisticView.businessFieldName LIKE '" + filter.getBusinessFieldString()[i].getFilter() + "')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }
      if (filter.getContactPersonGanz().length>0) {
         wAttr = wAttr + " AND ((statisticView.contactPersonGanz LIKE '%" + filter.getContactPersonGanz()[0].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         for(int i = 1; i < filter.getContactPersonGanz().length; ++i){
            wAttr = wAttr + " OR (statisticView.contactPersonGanz LIKE '%" + filter.getContactPersonGanz()[i].getFilter() + "%')"; //$NON-NLS-1$ //$NON-NLS-2$
         }
         wAttr = wAttr + ")";
      }


      try {

         Statement query = con.createStatement();
         System.out.println("SELECT " + sAttr + " FROM statisticView INNER JOIN CoopView ON statisticView.[coopID] = CoopView.[coopID] WHERE ((1=1)" + wAttr + ") " + ((gAttr.length() == 0) ? "" : "GROUP BY " )+ gAttr + ((gAttr.length() == 0) )); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
         ResultSet rs = query.executeQuery("SELECT " + sAttr + " FROM statisticView INNER JOIN CoopView ON statisticView.[coopID] = CoopView.[coopID] WHERE ((1=1)" + wAttr + ") " + ((gAttr.length() == 0) ? "" : "GROUP BY " ) + gAttr ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
```


----------



## VfL_Freak (21. Jun 2018)

Moin,

nutze bitte die Code-Tags !!!
So bekommt man ja Augenkrebs 

Und eine wirkliche Frage sehe ich auch nicht ... WO geht WAS schief??

VG Klaus


----------



## mrBrown (21. Jun 2018)

evelynblabla hat gesagt.:


> In meiner Datenbank werden die Datumsangaben "2018-06-02" gespeichert jedoch wählt der Nutzer auf der Benutzeroberfläche das Datumsformat 02.06.2018. Nun muss ich (im Quellcode markiert) die Daten konvertieren, damit die Abfrage durchgeführt werden kann.


Speicher das Datum in der Datenbank als Datum, parse das eingegeben Datum des Nutzers und du musst nur noch Daten vergleichen. Wenn du innerhalb deiner Applikation irgendwo das Datum formatiert benutzt, läuft was schief.

Den Code hab ich mir aber nicht näher angeguckt, den solltest du ganz dringend refactoren!


----------



## mihe7 (21. Jun 2018)

Schau Dir auch mal Connection#prepareStatement und die Setter von PreparedStatement an.


----------

