Tutorial

So verarbeiten Sie Excel-Zeitstempel

Einführung

Excel speichert Daten als fortlaufende Zahlen, die die Anzahl der Tage seit dem 1. Januar 1900 (oder dem 1. Januar 1904 auf dem Mac) darstellen. Für die Datenmigration, die API-Integration und die Arbeit mit datumsbasierten Analysen ist es wichtig zu verstehen, wie Excel mit Zeitstempeln umgeht. In diesem Leitfaden werden Konvertierungstechniken, Berechnungen und Best Practices behandelt.

Excel-Datumssystem verstehen

So speichert Excel Daten

Excel verwendet zwei Datumssysteme:

1900-Datumssystem (Windows – Standard)

  • Tag 1 = 1. Januar 1900
  • Dezimalbruch stellt die Tageszeit dar (z. B. 0,5 = Mittag)
  • Enthält einen Fehler: Excel behandelt 1900 als Schaltjahr (war es aber nicht)

1904-Datumssystem (Mac)

  • Tag 1 = 2. Januar 1904
  • Entwickelt, um den Fehler im Schaltjahr 1900 zu beheben – Wird standardmäßig in älteren Mac-Versionen von Excel verwendet

Wichtig: Überprüfen Sie immer, welches Datumssystem Ihre Excel-Datei verwendet, bevor Sie Konvertierungen durchführen. Gemischte Datumssysteme in derselben Arbeitsmappe können erhebliche Fehler verursachen.

Struktur der Seriennummer

Excel Date Number = Days since epoch + Fraction of day

Example: 44927.5
  = 44927 (days since Jan 1, 1900)
  + 0.5 (half day = 12:00 PM)
  = January 1, 2023, 12:00 PM

Grundlegende Konvertierungen

Excel-Datum zum Unix-Zeitstempel

Methode 1: Excel-Formel

Konvertieren Sie das serielle Excel-Datum in einen Unix-Zeitstempel (Sekunden seit dem 01.01.1970):

excel
=(A1 - DATE(1970,1,1)) * 86400

Where:
  A1 = Excel serial date (e.g., 44927.5)
  DATE(1970,1,1) = Unix epoch in Excel (25569)
  86400 = seconds per day

Profi-Tipp: Verwenden Sie benannte Bereiche für eine bessere Lesbarkeit:

excel
> =EPOCH_DATE * 86400
>
```> Wobei EPOCH_DATE als 25569 definiert ist

### Methode 2: Excel VBA-Funktion

Erstellen Sie eine wiederverwendbare VBA-Funktion für Konvertierungen:

vba Function ExcelToUnix(excelDate As Double) As Long ' Convert Excel serial date to Unix timestamp Dim epochDate As Date epochDate = #1/1/1970# ExcelToUnix = (excelDate - epochDate) * 86400 End Function

### Methode 3: Online-Konverter

Verwenden Sie unser Tool [Excel Timestamp Converter] (/excel-timestamp) für sofortige Konvertierungen ohne Formeln.

## Unix-Zeitstempel zum Excel-Datum

### Methode 1: Excel-Formel

Konvertieren Sie den Unix-Zeitstempel in das serielle Excel-Datum:

excel =(A1 / 86400) + DATE(1970,1,1)

Where: A1 = Unix timestamp in seconds 86400 = seconds per day DATE(1970,1,1) = Unix epoch in Excel (25569)

### Methode 2: Excel VBA-Funktion

vba Function UnixToExcel(unixTimestamp As Long) As Date ' Convert Unix timestamp to Excel date Dim epochDate As Date epochDate = #1/1/1970# UnixToExcel = (unixTimestamp / 86400) + epochDate End Function

## Datumsberechnungen

## Datumsarithmetik

### Tage addieren und subtrahieren

excel ' Add 7 days to a date =A1 + 7

' Subtract 30 days from a date =A1 - 30

' Calculate days between two dates =B1 - A1

### Zeit addieren und subtrahieren

excel ' Add 4 hours to a datetime =A1 + (4/24)

' Add 30 minutes to a datetime =A1 + (30/1440)

' Add 45 seconds to a datetime =A1 + (45/86400)

' Where: 24 = hours per day 1440 = minutes per day 86400 = seconds per day

> **Best Practice:** Verwenden Sie Zellbezüge für Zeiteinheiten, um eine harte Codierung zu vermeiden:
>

excel

=A1 + (B1/86400)


### Berechnung der Werktage

excel ' Calculate business days between two dates (excludes weekends) =NETWORKDAYS(A1, B1)

' Calculate business days excluding holidays =NETWORKDAYS(A1, B1, C1:C10)

> **Internationale Version:** Verwenden Sie NETWORKDAYS.INTL für benutzerdefinierte Wochenendmuster:
>

excel

=NETWORKDAYS.INTL(A1, B1, 11)



## Excel-Datumsfunktionen

## Wesentliche Datumsfunktionen

### Aktuelles Datum und Uhrzeit

excel ' Today's date (no time) =TODAY()

' Current date and time =NOW()

' Current time only =NOW() - TODAY()

' Extract time from datetime =MOD(A1, 1)

### Datumskomponenten extrahieren

excel ' Extract year =YEAR(A1)

' Extract month number (1-12) =MONTH(A1)

' Extract day of month =DAY(A1)

' Extract hour (0-23) =HOUR(A1)

' Extract minute (0-59) =MINUTE(A1)

' Extract second (0-59) =SECOND(A1)

### Daten aus Komponenten erstellen

excel ' Create date from year, month, day =DATE(2023, 1, 15)

' Create time from hour, minute, second =TIME(14, 30, 0)

' Combine date and time =DATE(2023, 1, 15) + TIME(14, 30, 0)

### Arbeiten mit Wochentagen

excel ' Get day of week (1=Sunday, 7=Saturday) =WEEKDAY(A1)

' Get day of week name =TEXT(A1, "dddd")

' Get weekday name (3-letter abbreviation) =TEXT(A1, "ddd")

' ISO week number =ISOWEEKNUM(A1)

' Week number in year =WEEKNUM(A1)

## Erweiterte Datumsoperationen

## Datumsrundung und -kürzung

### Auf Beginn der Periode kürzen

excel ' Truncate to start of day (remove time) =INT(A1)

' Round to nearest hour =ROUND(A1*24, 0)/24

' Round to nearest day =ROUND(A1, 0)

' Round down to start of month =EOMONTH(A1, -1) + 1

' Round down to start of year =DATE(YEAR(A1), 1, 1)

### Berechnungen zum Periodenende

excel ' End of current month =EOMONTH(A1, 0)

' End of next month =EOMONTH(A1, 1)

' End of previous month =EOMONTH(A1, -1)

' End of current year =DATE(YEAR(A1), 12, 31)

## Bedingte Datumslogik

### IF mit Datumsangaben verwenden

excel ' Check if date is in the past =IF(A1 < TODAY(), "Past", "Future")

' Check if date is within last 30 days =IF(AND(A1 >= TODAY()-30, A1 <= TODAY()), "Recent", "Old")

' Calculate age =IF(MONTH(TODAY()) >= MONTH(A1), YEAR(TODAY()) - YEAR(A1), YEAR(TODAY()) - YEAR(A1) - 1)

### Komplexe Datumslogik

excel ' Calculate fiscal year (starts July 1) =IF(MONTH(A1) >= 7, YEAR(A1) + 1, YEAR(A1))

' Calculate quarter =ROUNDUP(MONTH(A1)/3, 0)

' Add business days (skipping weekends) =WORKDAY(A1, 10)

## Datumsformatierung

## Benutzerdefinierte Datumsformate

### Formatcodes
```text
Format Code Examples:

d          Day (1-31)
dd         Day with leading zero (01-31)
ddd        Day abbreviation (Mon)
dddd       Full day name (Monday)

m          Month (1-12)
mm         Month with leading zero (01-12)
mmm        Month abbreviation (Jan)
mmmm       Full month name (January)

yy         2-digit year (23)
yyyy       4-digit year (2023)

h          Hour (0-23)
hh         Hour with leading zero (00-23)
m          Minute (0-59)
mm         Minute with leading zero (00-59)
s          Second (0-59)
ss         Second with leading zero (00-59)

AM/PM      AM/PM indicator

Anwenden von Formaten

excel
' Apply date format via formula
=TEXT(A1, "yyyy-mm-dd")

' Apply datetime format with seconds
=TEXT(A1, "yyyy-mm-dd hh:mm:ss")

' Custom format: "January 15, 2023 at 2:30 PM"
=TEXT(A1, "mmmm dd, yyyy at h:mm AM/PM")

' ISO 8601 format
=TEXT(A1, "yyyy-mm-ddThh:mm:ss")

Wichtig: TEXT() gibt einen String-Wert zurück. Verwenden Sie zuerst numerische Operationen und formatieren Sie sie am Ende.

Häufige Fallstricke

Datumssystemkonflikte

1900 vs. 1904 Datumssystem

Problem: Gemischte Datumssysteme verursachen erhebliche Berechnungsfehler.

excel
' Check if workbook uses 1904 date system
' Excel Options > Advanced > When calculating this workbook > Use 1904 date system

Lösung: Verwenden Sie immer Extras > Optionen > Erweitert, um die Datumssystemeinstellungen zu überprüfen, bevor Sie mit Datumsangaben arbeiten.

Schaltjahr-Käfer (1900)

Excel behandelt 1900 fälschlicherweise als Schaltjahr, einschließlich des 29. Februar 1900 (den es nicht gab):

excel
' March 1, 1900 in Excel
=DATE(1900, 3, 1)  ' Returns 61 (correct)

' February 28, 1900 in Excel
=DATE(1900, 2, 28)  ' Returns 59 (correct)

' February 29, 1900 (DOESN'T EXIST)
=DATE(1900, 2, 29)  ' Returns 60 (incorrect - this day never happened)

Problemumgehung: Das Datumssystem von 1904 behebt diesen Fehler, führt jedoch zu Kompatibilitätsproblemen mit Windows Excel-Dateien.

Zeitzonenprobleme

Excel speichert Daten ohne Zeitzoneninformationen:

excel
' Current time in Excel
=NOW()  ' Returns local system time

Best Practice: Speichern Sie UTC-Zeitstempel in einer separaten Spalte und pflegen Sie Zeitzonen-Metadaten für Konvertierungen.

Text- und Datumsformate

Problem: Als Text gespeicherte Daten können nicht in Berechnungen verwendet werden.

excel
' Check if cell contains date or text
=ISNUMBER(A1)  ' TRUE for dates, FALSE for text

' Convert text to date
=DATEVALUE("2023-01-15")
=TIMEVALUE("14:30:00")

' Parse combined date and time text
=DATEVALUE("2023-01-15") + TIMEVALUE("14:30:00")

Leistungsoptimierung

Berechnungsleistung

Vermeiden Sie flüchtige Funktionen

Problem: Funktionen wie NOW() und TODAY() werden bei jeder Änderung neu berechnet, was große Arbeitsmappen verlangsamt.

Lösung: Ergebnisse flüchtiger Funktionen in statischen Zellen speichern:

excel
> ' BAD: Every row recalculates
> =IF(A1 > NOW(), "Future", "Past")
>
> ' GOOD: Calculate once in cell B1
> B1: =NOW()
> A2: =IF(A1 > $B$1, "Future", "Past")
>
```>
> ### Benannte Bereiche verwenden
>
>

excel

' Define named ranges (Formulas > Name Manager) EPOCH_DATE = 25569 SECONDS_PER_DAY = 86400

' Use in formulas =(A1 - EPOCH_DATE) * SECONDS_PER_DAY

> **Vorteil:** Benannte Bereiche verbessern die Lesbarkeit und erleichtern die Pflege von Formeln.

### Array-Formeln für Stapeloperationen

excel ' Convert multiple Unix timestamps at once (Excel 365) =A2:A100/86400 + DATE(1970,1,1)

' Calculate ages for a range =YEAR(TODAY()) - YEAR(A2:A100)

## Integrationsbeispiele

## Exportieren in CSV

Beim Exportieren von Excel-Daten in CSV:

excel ' Format dates as ISO 8601 before exporting =TEXT(A1, "yyyy-mm-ddThh:mm:ss")

> **Best Practice:** Speichern Sie als CSV mit UTF-8-Kodierung, um Datumsformate beizubehalten.

## Importieren von der API

Analysieren Sie JSON-Daten von APIs:

excel ' Assuming cell A1 contains: 1673761800 (Unix timestamp) ' Convert to Excel date =(A1/86400) + DATE(1970,1,1)

' Format as readable date =TEXT((A1/86400) + DATE(1970,1,1), "yyyy-mm-dd hh:mm:ss")

## Datenbankintegration

Arbeiten mit SQL-Datenbanken:

excel ' Prepare date for SQL INSERT =TEXT(A1, "yyyy-mm-dd hh:mm:ss") ' Returns: "2023-01-15 14:30:00"

' Convert SQL DATETIME to Excel =DATEVALUE(LEFT(A1, 10)) + TIMEVALUE(MID(A1, 12, 8))

## Best Practices-Zusammenfassung

## Checkliste für den Umgang mit Daten
```text
✅ Always verify date system (1900 vs 1904) before calculations
✅ Use named ranges for constants (EPOCH_DATE, SECONDS_PER_DAY)
✅ Store volatile function results (NOW(), TODAY()) in static cells
✅ Use TEXT() only for final display formatting
✅ Validate date formats before calculations (ISNUMBER, DATEVALUE)
✅ Use NETWORKDAYS for business day calculations
✅ Apply consistent date formatting across workbooks
✅ Document date assumptions (timezones, epoch references)
✅ Test edge cases (leap years, month boundaries)
❌ Don't mix text and date formats in calculations
❌ Don't use volatile functions in large datasets
❌ Don't assume dates are in UTC without documentation
❌ Don't hardcode timezone offsets in formulas
❌ Don't ignore the 1900 leap year bug for historical dates

Fehlerbehebung bei häufigen Problemen

Problem: Datumsangaben werden als Zahlen angezeigt

excel
' Solution 1: Format as date
' Select cells > Right-click > Format Cells > Date

' Solution 2: Use TEXT() function
=TEXT(A1, "yyyy-mm-dd")

' Solution 3: Check for text dates
' If ISNUMBER(A1) returns FALSE, use:
=DATEVALUE(A1)

Problem: Falsche Datumsberechnungen

excel
' Check 1: Verify date system
' Excel Options > Advanced > Use 1904 date system

' Check 2: Ensure consistent units
' Days: =A1 + 7
' Hours: =A1 + (4/24)
' Minutes: =A1 + (30/1440)
' Seconds: =A1 + (45/86400)

' Check 3: Verify date components
' Ensure DATE() has correct arguments: YEAR, MONTH, DAY

Problem: Fehler bei der Zeitzonenkonvertierung

excel
' Solution: Maintain separate timezone column
A1: Excel timestamp
B1: Timezone offset (e.g., -5 for EST)
C1: =A1 + (B1/24)

Verwandte Tools

Zusätzliche Ressourcen

Für eine umfangreiche Datenverarbeitung (>10.000 Zeilen) sollten Sie für eine bessere Leistung die Verwendung von Power Query oder VBA-Makros in Betracht ziehen. Excel-Funktionen sind für die interaktive Nutzung optimiert und können bei großen Datensätzen langsam werden.