Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfT7b-0006p5-V0 for pgsql-general@arkaria.postgresql.org; Fri, 04 Jan 2019 17:19:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gfT7a-0000RE-My for pgsql-general@arkaria.postgresql.org; Fri, 04 Jan 2019 17:18:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfT7a-0000R5-CZ for pgsql-general@lists.postgresql.org; Fri, 04 Jan 2019 17:18:58 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfT7Y-0002Gq-5O for pgsql-general@lists.postgresql.org; Fri, 04 Jan 2019 17:18:57 +0000 Received: by mail-pf1-x436.google.com with SMTP id 64so18584360pfr.9 for ; Fri, 04 Jan 2019 09:18:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=wOTP0msv9Dz14fiAlqQjZXZMwIXpBqSE78a2j1UDnho=; b=U6lMFxqqufbOF5ByeDfLGwbZ5KbCU0obtR10ZXMEltXLFLSnmhMomp/hm+tdOFoB3h 7YKvctWuWHBYj5HICVXCboksYiYUA4ZpJoGQILkYb7oyCIPXJwKUUpapwqgoDIj1ZYP3 z4kzzPj2KAqooZKAyjmnffG72Y0izAMeIyDHzQmfYuCJ2yHQfBUcD/jYLOe4BoXtXnm1 eMPcDayZqnAeoZkTsJ6e1NJz0Dgn7Aj9Gulud3SjxHS6AR/4MCUyWwlOJbNo6XKCGywm +lQXCP7CK2X82aywZVAhBt57N/PVniHcC77dmrXg5KmM2cbpTtpLLEK1mDGDAb8uekm6 Mzsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=wOTP0msv9Dz14fiAlqQjZXZMwIXpBqSE78a2j1UDnho=; b=GAWBEFxhw0lBVfcdV4KhzzeLmUcbzQqr2BEHIw5WsX4Wgd+JErn9201UraZ0/o9OMN aqmojwcp2yery8eOMC+G8bVdq1t8WfZgfF2E0XN4yFDawiswWahG9BpVyHeSzfugrOCi UxR93PQqNzdChSxdFLeLkHjDWxg2wBiE6d7kBfG7KtSLm90UErsem1kuoO0ZShnYgR2J MRQKWU7ChGhz59iugnfvURJAiIz8d/5GkgtPIDRe8S0ObDyO1uETqxdL3JlzI7sw2MBf v8i/aKmEtVfKMxDc0LRqEr5bsfI5f/iRfdXSlZM86eyCjDbM0Pkxce5iDXwiP6qu6d4p x7uA== X-Gm-Message-State: AA+aEWbQyWazeAwFXq0VKBHM0lBV5TlIkMDkq1rI9EpH7wtm/bWQQyo/ T4VAC7/dlnFv7Dx0xrZprkTTjqoR X-Google-Smtp-Source: ALg8bN7/c9uWUhAgbaUnyijcV/YB9d6aiOc2T7t9uVrID08fX5RE11ogolF7TUEeOF79h3c9RwRVow== X-Received: by 2002:a62:76cc:: with SMTP id r195mr52815826pfc.38.1546622333030; Fri, 04 Jan 2019 09:18:53 -0800 (PST) Received: from [10.104.134.14] ([155.100.47.6]) by smtp.gmail.com with ESMTPSA id 184sm82829689pfe.106.2019.01.04.09.18.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Jan 2019 09:18:52 -0800 (PST) Subject: Re: Comparing dates in DDL To: pgsql-general@lists.postgresql.org References: From: Rob Sargent Message-ID: Date: Fri, 4 Jan 2019 10:18:51 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/4/19 10:12 AM, Igor Korot wrote: > Hi, Rich, > > On Fri, Jan 4, 2019 at 10:53 AM Rich Shepard wrote: >> I have a projects table that includes these two columns: >> >> start_date date DEFAULT CURRENT_DATE, >> end_date date >> CONSTRAINT valid_start_date >> CHECK (start_date <= end_date), >> >> 1. Do I need a DEFAULT value for the end_date? >> 2. If so, please suggest a value for it. > start_date.day() + 1? > > Thank you. > >> TIA, >> >> Rich >> Is the end_date always knowable at record insert? CHECK(end_date is null or start_date <= end_date)