The filter that drops the last day

मॉड्यूल 1: Analyze with AI, and catch its mistakes

कोर्स की रूपरेखा

यह पाठ अभी आपकी भाषा में नहीं है, इसलिए यहाँ अंग्रेज़ी में है।

झटपट जाँच

Guess first, no penalty. An AI writes WHERE created_at BETWEEN '2026-09-01' AND '2026-09-30' for September sales. created_at holds a date and a time. Which orders does it miss?

A timestamp is a date plus a time, such as 2026-09-30 14:05:00. When you compare a timestamp with a plain date, the date means midnight at the start of that day. So an end date in BETWEEN quietly cuts off the last day of the month.

AI tools write BETWEEN a lot, because it reads naturally. The safer pattern is a half-open range: everything from the first day, up to but not including the day after the last.

Time zones move the edges too. If created_at is stored in UTC (the world reference time), a sale at 11 pm in New York on 30 September is already 1 October in UTC. Decide which day it belongs to, and write that rule into the prompt (the message you send to the AI).

A worked example

Filter:  WHERE created_at >= '2026-09-01'
           AND created_at <  '2026-10-01'
Rule:    created_at is UTC. Finance reports September in UTC too.
Check:   SELECT MIN(created_at), MAX(created_at) FROM ... (same filter)
Result:  2026-09-01 00:03:12   2026-09-30 23:58:40
         First and last day are both there.

खाली जगह भरें

Fill the gaps.

Date filter

WHERE created_at >= '2026-09-01' AND created_at Then I check the , and I say which the dates are in.

Try it

आपके स्टेप, लगभग 2 मिनट

1 में से 0
  1. 1.Run MIN and MAX on the date column of one monthly report query, with the same filter, and check both edges are there. Add it to your checklist.2 मिनट

प्रैक्टिस

2 में से सवाल 1

Which filter catches every order placed in September when created_at is a timestamp?

AI ट्यूटर

इस पाठ के बारे में सवाल पूछें और “करके देखें” वाले काम में मदद पाएँ। ट्यूटर Learn Pro का हिस्सा है।

Learn Pro देखें