0

Datuma1 und Datum 2 soll am ende ein zahl sein

hallo zusammen 

beispiel: 22.02.2023 und 22.04.2023 als resultat 2 

 

wie bekomme ich das ?

 

Liebe grüsse

Alan

10 Antworten

null
    • mirko3
    • vor 1 Jahr
    • Gemeldet - anzeigen

    Was willst Du den berechnen? Die Monatsdifferenz? Mirko

      • alan_iselin
      • vor 1 Jahr
      • Gemeldet - anzeigen

      Mirko hallo Mirko 

      ja es muss ein zahlt sein zum beispiel januar bis februar 1 monat

    • alan_iselin
    • vor 1 Jahr
    • Gemeldet - anzeigen

    diese formel in Screenshot funktioniert nicht

    • mirko3
    • vor 1 Jahr
    • Gemeldet - anzeigen

    Rechnung.'Data Dal' gibt wahrscheinlich ein Array wieder, kein Datum. Außerdem ist das Ergebnis der Funktion ein String und keine Zahl. Versuche es mal so wie unten stehend. Wenn es dann noch nicht geht, dann gib etwas mehr Kontext.

    first(Rechnung.month('Data Al'))-first(Rechnung.month('Data Dal'))
    

    Für die Funktion muß es so heißen

    TimeInterval(datetime(first(Rechnung.'Data Dal')),datetime(first(Rechnung.'Data Al')))
      • alan_iselin
      • vor 1 Jahr
      • Gemeldet - anzeigen

      Mirko  Hallo Mirko 

      vielen Dank für deine Mühe 

      es ist eine rote zahl, 1, ich sende das screenshot

      Gruss

      • mirko3
      • vor 1 Jahr
      • Gemeldet - anzeigen

      alan. iselin Der gesamte Code aus dem Beispiel muß eingefügt werden. Die letzte Zeile ist nur der Aufruf der Funktion. Versuche das mal so. 

      function TimeInterval(first : datetime,second : datetime) do
          let dateTime1 := first;
          let dateTime2 := second;
          let D1 := if dateTime1 < dateTime2 then
                  date(dateTime1)
              else
                  date(dateTime2)
              end;
          let D2 := if dateTime1 < dateTime2 then
                  date(dateTime2)
              else
                  date(dateTime1)
              end;
          "Funktion zur Überprüfung eines Datums, ob es in einem Schaltjahr liegt";
          function isLeapYear(num : number) do
              if date(num, 2, 29) != date(num, 3, 1) then
                  true
              else
                  false
              end
      end;
          let timeZone := number(format(dateTime1, "ZZ")) - number(format(dateTime2, "ZZ"));
          let timeDuration := 1;
          switch timeDuration do
          case timeZone = -100:
              (timeDuration := number(time(24, 0) - time(dateTime1) + time(dateTime2) - time(1, 0)))
          case timeZone = 100:
              (timeDuration := number(time(24, 0) - time(dateTime1) + time(dateTime2) + time(1, 0)))
          case timeZone = 0:
              (timeDuration := number(time(24, 0) - time(dateTime1) + time(dateTime2)))
          end;
          "Funktion als Variable zur Überprüfung ob ein Zeitabstand >= ein Tag ist.";
          let isFullDayOrMore := timeDuration - 86400000 >= 0;
          let oneDayMs := 86400000;
          let oneHourMs := 3600000;
          let oneMinuteMs := 60000;
          let dayMs := floor(timeDuration / oneDayMs) * oneDayMs;
          let hourMs := floor((timeDuration - dayMs) / oneHourMs) * oneHourMs;
          let minuteMs := floor((timeDuration - dayMs - hourMs) / oneMinuteMs) * oneMinuteMs;
          let HH := hourMs / oneHourMs;
          let mm := minuteMs / oneMinuteMs;
          let DD := 1;
          let MM := 1;
          let YY := 1;
          if D1 = null or D2 = null then
              ""
          else
              if D1 = D2 and timeDuration = 86400000 then
                  "Anfang = Ende"
              else
                  "Berechnung der Tage";
                  let sameDayOfD1InMonthBeforeOfD2 := day(date(year(D2), month(D2) - 1, day(D1)));
                  let lastDayOfD1 := day(date(year(D2), month(D2), 0));
                  switch DD do
                  case day(D2) = day(D1) and isFullDayOrMore:
                      (DD := 0)
                  case day(D2) > day(D1) and isFullDayOrMore:
                      (DD := day(D2) - day(D1))
                  case day(D2) = day(D1) and not isFullDayOrMore:
                      (DD := lastDayOfD1 - sameDayOfD1InMonthBeforeOfD2 + day(D2) - 1)
                  case day(D2) > day(D1) - 1 and not isFullDayOrMore:
                      (DD := day(D2) - day(D1) - 1)
                  case day(D2) < day(D1) and not isFullDayOrMore and isLeapYear(year(D1)) and month(D1) = 2 and month(D2) = 3:
                      (DD := 29 - if day(D1) = 29 then
                              29
                          else
                              sameDayOfD1InMonthBeforeOfD2
                          end + day(D2) - 1)
                  case day(D2) < day(D1) and isFullDayOrMore and isLeapYear(year(D1)) and month(D1) = 2 and month(D2) = 3:
                      (DD := 29 - if day(D1) = 29 then
                              29
                          else
                              sameDayOfD1InMonthBeforeOfD2
                          end + day(D2))
                  case day(D2) < day(D1) and not isFullDayOrMore:
                      (DD := lastDayOfD1 - sameDayOfD1InMonthBeforeOfD2 + day(D2) - 1)
                  case day(D2) < day(D1) and isFullDayOrMore:
                      (DD := lastDayOfD1 - sameDayOfD1InMonthBeforeOfD2 + day(D2))
                  end;
                  "Berechnung der Monate";
                  switch MM do
                  case month(D1) < month(D2) and day(D1) <= day(D2) and isFullDayOrMore:
                      (MM := month(D2) - month(D1))
                  case month(D1) < month(D2) and day(D1) < day(D2) and not isFullDayOrMore:
                      (MM := month(D2) - month(D1))
                  case month(D1) < month(D2) and day(D1) > day(D2) and isFullDayOrMore:
                      (MM := month(D2) - month(D1) - 1)
                  case month(D1) < month(D2) and day(D1) >= day(D2) and not isFullDayOrMore:
                      (MM := month(D2) - month(D1) - 1)
                  case month(D1) > month(D2) and day(D1) > day(D2) and isFullDayOrMore:
                      (MM := 12 - month(D1) + month(D2) - 1)
                  case month(D1) > month(D2) and day(D1) >= day(D2) and not isFullDayOrMore:
                      (MM := 12 - month(D1) + month(D2) - 1)
                  case month(D1) > month(D2) and day(D1) <= day(D2) and isFullDayOrMore:
                      (MM := 12 - month(D1) + month(D2))
                  case month(D1) > month(D2) and day(D1) < day(D2) and not isFullDayOrMore:
                      (MM := 12 - month(D1) + month(D2))
                  case month(D1) = month(D2) and day(D1) <= day(D2) and isFullDayOrMore:
                      (MM := 0)
                  case month(D1) = month(D2) and day(D1) < day(D2) and not isFullDayOrMore:
                      (MM := 0)
                  case month(D1) = month(D2) and day(D1) > day(D2) and isFullDayOrMore:
                      (MM := 11)
                  case month(D1) = month(D2) and day(D1) >= day(D2) and not isFullDayOrMore:
                      (MM := 11)
                  end;
                  "Berechnung der Jahre";
                  switch YY do
                  case month(D1) < month(D2):
                      (YY := year(D2) - year(D1))
                  case month(D1) = month(D2) and day(D1) <= day(D2) and isFullDayOrMore:
                      (YY := year(D2) - year(D1))
                  case month(D1) = month(D2) and day(D1) = day(D2) and not isFullDayOrMore:
                      (YY := year(D2) - year(D1) - 1)
                  case month(D1) = month(D2) and day(D1) < day(D2) and not isFullDayOrMore:
                      (YY := year(D2) - year(D1))
                  case month(D1) = month(D2) and day(D1) > day(D2):
                      (YY := year(D2) - year(D1) - 1)
                  case month(D1) > month(D2):
                      (YY := year(D2) - year(D1) - 1)
                  end
              end
          end;
          "Das Anordnen der Ergebnisse.";
          let yearResult := "";
          switch yearResult != null do
          case YY = 0:
              (yearResult := "")
          case YY = 1 and MM = 0 and DD = 0 and HH = 0 and mm = 0:
              (yearResult := YY + " Jahr" + "")
          case YY = 1:
              (yearResult := YY + " Jahr" + ", ")
          case YY > 1 and MM = 0 and DD = 0 and HH = 0 and mm = 0:
              (yearResult := YY + " Jahre" + "")
          case YY > 1:
              (yearResult := YY + " Jahre" + ", ")
          end;
          let monthResult := "";
          switch monthResult != null do
          case MM = 0:
              (monthResult := "")
          case MM = 1 and DD = 0 and HH = 0 and mm = 0:
              (monthResult := MM + " Monat" + "")
          case MM = 1:
              (monthResult := MM + " Monat" + ", ")
          case MM > 1 and DD = 0 and HH = 0 and mm = 0:
              (monthResult := MM + " Monate" + "")
          case MM > 1:
              (monthResult := MM + " Monate" + ", ")
          end;
          let dayResult := "";
          switch dayResult != null do
          case DD = 0:
              (dayResult := "")
          case DD = 1 and HH = 0 and mm = 0:
              (dayResult := DD + " Tag" + "")
          case DD = 1:
              (dayResult := DD + " Tag" + ", ")
          case DD > 1 and HH = 0 and mm = 0:
              (dayResult := DD + " Tage" + "")
          case DD > 1:
              (dayResult := DD + " Tage" + ", ")
          end;
          let hourResult := "";
          switch hourResult != null do
          case HH = 0:
              (hourResult := "")
          case HH = 1 and mm = 0:
              (hourResult := HH + " Stunde" + "")
          case HH = 1:
              (hourResult := HH + " Stunde" + ", ")
          case HH > 1 and mm = 0:
              (hourResult := HH + " Stunden" + "")
          case HH > 1:
              (hourResult := HH + " Stunden" + ", ")
          end;
          let minuteResult := "";
          switch minuteResult != null do
          case mm = 0:
              (minuteResult := "")
          case mm = 1:
              (minuteResult := mm + " Minute")
          case mm > 1:
              (minuteResult := mm + " Minuten")
          end;
          yearResult + monthResult + dayResult + hourResult + minuteResult
      end;
      TimeInterval(datetime(first(Rechnung.'Data Dal')),datetime(first(Rechnung.'Data Al')))
      
      • alan_iselin
      • vor 1 Jahr
      • Gemeldet - anzeigen

      Mirko Mirko Tu bist ein TITAN 
      Danke Dir viel mal

    • alan_iselin
    • vor 1 Jahr
    • Gemeldet - anzeigen

    eine frage noch sorry 
    wenn ich die vorlage installiere auf ein mac auf italienisch kommt dann der name auf Italienisch ?

    • mirko3
    • vor 1 Jahr
    • Gemeldet - anzeigen

    Leider nein. Aber hier sind ein paar kleine Hinweise.

      • alan_iselin
      • vor 1 Jahr
      • Gemeldet - anzeigen

      Mirko Du bist einfach genial danke sehr 🙂

Content aside

  • vor 1 JahrZuletzt aktiv
  • 10Antworten
  • 47Ansichten
  • 2 Folge bereits