timestampExtract() reads a calendar component—such as year, month, or day—from a timestamp. An optional timezone shifts the calendar used for extraction.
Import from the pipelines entry point:
js
import { timestampExtract, field } from '@react-native-firebase/firestore/pipelines';js
import { getFirestore } from '@react-native-firebase/firestore';
import { execute, field, timestampExtract } from '@react-native-firebase/firestore/pipelines';
const db = getFirestore('your-enterprise-database-id');
const snapshot = await execute(
db
.pipeline()
.collection('events')
.select(
timestampExtract(field('createdAt'), 'year').as('createdYear'),
timestampExtract('createdAt', 'month').as('createdMonth'),
field('createdAt').timestampExtract('day').as('createdDay'),
),
);
snapshot.results.forEach(row => {
console.log(row.data().createdYear, row.data().createdMonth, row.data().createdDay);
});| Helper | Use when |
|---|---|
timestampExtract | Read year, month, day, or other calendar part |
timestampTruncate | Bucket timestamps to a granularity |
timestampDiff | Measure elapsed time between timestamps |
TimePart | Type for part literals such as 'year' |
See the firebase-js-sdk timestampExtract declaration for full overload signatures and supported TimePart values.

Core / App