A weekly report built on the same rows can give different totals in PostgreSQL and BigQuery because the two engines start the week on different days. PostgreSQL's week is the ISO week, which starts on Monday. BigQuery's DATE_TRUNC(date, WEEK) starts the week on Sunday. Pick one convention and write it into both queries explicitly. Months need no such care: the first of the month is the same everywhere.
What each engine calls a week
PostgreSQL. The PostgreSQL documentation defines the week field as the ISO 8601 week number: weeks begin on Monday, and week 1 of a year is the week that holds January 4. isodow numbers the days Monday (1) to Sunday (7), while dow numbers them Sunday (0) to Saturday (6).
date_trunc takes a timestamp, a timestamp with time zone or an interval. A date is cast to a timestamp first, so the result is a timestamp, not a date. Cast it back with ::date, or your week column carries a midnight time and, with a time zone, an offset that a BI tool may shift.
BigQuery. In GoogleSQL, WEEK is the same as WEEK(SUNDAY). For Monday weeks, write WEEK(MONDAY) or ISOWEEK. DATE_TRUNC returns the same type it was given, so a DATE in gives a DATE out. EXTRACT(WEEK ...) counts weeks 0 to 53 starting on Sunday, and days before the year's first Sunday fall in week 0; EXTRACT(ISOWEEK ...) counts 1 to 53 starting on Monday.
The column you roll up
The PostgreSQL destination creates date as a date column, the metrics impressions, clicks, cost, conversions, conversion_value, ctr, cpc, cpm and cpa as double precision, a platform's numeric extras as double precision too, and other columns such as network and currency as text. When the BigQuery destination is available, it will create date as DATE; that destination is coming.
Weekly totals in PostgreSQL, with Monday weeks:
SELECT
date_trunc('week', date)::date AS week_start,
network,
currency,
SUM(cost) AS cost,
SUM(clicks) AS clicks,
SUM(impressions) AS impressions,
SUM(conversions) AS conversions,
SUM(conversion_value) AS conversion_value
FROM public.ad_spend
GROUP BY 1, 2, 3
ORDER BY 1, 2, 3;
The same shape in BigQuery, also with Monday weeks:
SELECT
DATE_TRUNC(date, WEEK(MONDAY)) AS week_start,
network,
currency,
SUM(cost) AS cost,
SUM(clicks) AS clicks,
SUM(impressions) AS impressions,
SUM(conversions) AS conversions,
SUM(conversion_value) AS conversion_value
FROM my_dataset.ad_spend
GROUP BY 1, 2, 3
ORDER BY 1, 2, 3;
If your team reports Sunday-to-Saturday weeks, change the BigQuery side to WEEK and the PostgreSQL side to (date - extract(dow FROM date)::int), which moves every day back to its Sunday. For months, use date_trunc('month', date)::date in PostgreSQL and DATE_TRUNC(date, MONTH) in BigQuery. Keep currency in the grouping: adding cost in two currencies gives a number in neither.
Week numbers around January 1
An ISO year and a calendar year disagree for a few days around New Year. PostgreSQL's documentation gives January 1, 2005 as week 53 of 2004, and December 31, 2012 as week 1 of 2013. A label built from extract(year ...) and extract(week ...) then reads "2005-W53" for the first days of January 2005, so it sorts next to late December 2005 instead of next to the end of 2004.
Pair the week with the ISO year instead: extract(isoyear FROM date) with extract(week FROM date) in PostgreSQL, and EXTRACT(ISOYEAR FROM date) with EXTRACT(ISOWEEK FROM date) in BigQuery. BigQuery's own example shows January 1 and 2, 2016 as ISO year 2015, week 53. The simplest fix is to label weeks by their start date, as the queries above do: a date sorts correctly and never needs a year beside it.
Which numbers you may add up
Rolling the date column up to a week or month is safe for the counts and money: cost, clicks, impressions, conversions and conversion_value add up across days. The ratio columns do not. ctr, cpc, cpm and cpa hold each day's own ratio, and the sum or the average of seven daily CPCs is not the week's CPC. Recompute each ratio from the summed parts, for example the week's CPC as summed cost over summed clicks, with NULLIF on the divisor so a week without clicks gives null rather than an error. Compute CTR, CPC, CPA and ROAS from sums has the full set.
Columns that count people, such as reach or unique users, are not additive across days at all; see non-additive metrics. Platform extras keep dotted names in PostgreSQL and need double quotes, as in SUM("extra.sessions") on a GA4 table; see quoting extra columns.
The latest week keeps moving
A routine sync pulls recent days again, because platforms keep restating them: 7 days by default, and longer for some platforms, such as 31 days for Google Ads. Each run replaces its date range in your table, so the current week and the weeks just before it can change after you first report them. Compare closed weeks against closed weeks, and mark the current week as partial in your dashboard.