Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qA0wJ-0000iX-LK for pgsql-admin@arkaria.postgresql.org; Fri, 16 Jun 2023 04:19:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qA0wG-0006Cm-M0 for pgsql-admin@arkaria.postgresql.org; Fri, 16 Jun 2023 04:19:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qA0wG-0006Cc-Ad for pgsql-admin@lists.postgresql.org; Fri, 16 Jun 2023 04:19:56 +0000 Received: from mail-qt1-x833.google.com ([2607:f8b0:4864:20::833]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qA0wD-002h84-BL for pgsql-admin@lists.postgresql.org; Fri, 16 Jun 2023 04:19:55 +0000 Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-3f9cf20da51so3108521cf.2 for ; Thu, 15 Jun 2023 21:19:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686889191; x=1689481191; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hItTujdJ8k5ElDkbq5p5W7UzWqgrPvOfNP11AMm88HU=; b=PdRA39gyJTZ16fo7Ry9Ub0MMrp1Q52d5tHM+o5w7G2G1NEr8MQvxkjPgSjNBXoFe8k zmVVujEcqGP6oh5gDb1hUccoD0GnUXpRIY0JO7zlnks1fpSsf3xpO2MtDrkuzQjXdpgB 1zCWV6DObGnbjAreE6CG3EeyKNJs3GnKMmJaUCmQuAQ9tPoqj5w2kcHSio+4/i1onNsa t1h+mIyLw8uXD6L7X6tazZ3TD6B2Q0hlW/ZteKvR9fRZ50gH/yG9/PLrKDvj4ZDlFTGJ vjwtphF6u71qLhKx9zuqGUax4tid9iZTSbgtjJuhfiXAiwKBIKCUEfXs3s6xJe5itZIA uENA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686889191; x=1689481191; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hItTujdJ8k5ElDkbq5p5W7UzWqgrPvOfNP11AMm88HU=; b=JOAg520W3tLf6Tcnbqky6j5XHTqOlxsmDK2UyGpTZX3ly9NVuoDeJWteDXr6q9F9vI YDIVvkQzsU01lugpYk95pCeDHH1S7zzmfhfkiuQw/sIPCIUj9dr0aoyEAgapH87i32nS gxUDuXtlXiSDKLPrRfVwL+/fRKR5svIMW1GS8yx44kieJnzwML+4Uom6ne+KQ68zivTH GpBQci/1hwDbFPue5aBW3SvmHfVJAnP9lpM8BvsLLdNFn8Ad8lRRK1Zwa7YWq6AIS0s8 VFUeC++8IfCipDjQJKXFVuATub+JjWI8MCj+akxN/hx/0nJo5Y7xCTYNqEIX4Rdo94Ng +msg== X-Gm-Message-State: AC+VfDxUY0JKY221GJlV3N9FqRztZon0A1QgyLTsb/O2Gs9SXKKm6FSn yIUgqv3WzxGxTde9M8a3O2W9saVt6a/xXA== X-Google-Smtp-Source: ACHHUZ7IJbmHR3E/0EEGK4v5KfZ7UJ+w8USv2TDdVI/Zzh80GmJ9CR6suDD0qq8Rv80L9ylE5pu7Ag== X-Received: by 2002:a05:622a:1041:b0:3f4:dec2:76c3 with SMTP id f1-20020a05622a104100b003f4dec276c3mr1464368qte.22.1686889191361; Thu, 15 Jun 2023 21:19:51 -0700 (PDT) Received: from ?IPv6:2601:14b:4100:252f:b168:39ff:a759:546? ([2601:14b:4100:252f:b168:39ff:a759:546]) by smtp.gmail.com with ESMTPSA id fy26-20020a05622a5a1a00b003f86bc1753bsm6977479qtb.80.2023.06.15.21.19.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jun 2023 21:19:51 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.7\)) Subject: Re: Conversion from Number to Date From: Ed Sabol In-Reply-To: Date: Fri, 16 Jun 2023 00:19:49 -0400 Cc: M Sarwar Content-Transfer-Encoding: quoted-printable Message-Id: <14F13EFA-4298-44FF-ABD8-4913FBDCB212@gmail.com> References: To: Pgsql-admin X-Mailer: Apple Mail (2.3445.9.7) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Jun 15, 2023, at 10:23 PM, M Sarwar wrote: > Output: > 478 "44795.7306776851" "44795.731708" = 44795.73067768510 44795.73170800000 > 479 "44795.58143" "44795.58246" = 44795.58143000000 44795.58246000000 > 480 "44795.5714184259" "44795.572495" = 44795.57141842590 44795.57249500000 > =20 > During the data load from CSV files to the database, the above = START_TIME and STOP_TIME date column data arrived as number value. > Now I need to translate the START_TIME and STOP_TIME back to DATE = format. >=20 > I am unable to find any documentation or help from the internet. > =20 > Does it make sense or did I mess up something? Where did your CSV files come from? Just guessing, but those look like = Modified Julian Dates (MJD). See = https://en.wikipedia.org/wiki/Julian_day#Variants 44795.731708 MJD corresponds to 1981-07-10 17:33:39 UTC. Is that the era = your data is from? If you add 2400000.5 to an MJD value, you get the Julian Date (JD). If you then subtract 2440587.5 and multiply the result by 86400, you get = Unix time (the number of seconds since January 1, 1970), excluding leap = seconds. Putting those together means, if you subtract 40587 from those numbers = and multiply by 86400 and then use the PostgreSQL function = to_timestamp(), you can convert them to timestamps. # SET timezone=3D'utc'; SET # SELECT to_timestamp((44795.731708 - 40587.0)*86400); to_timestamp =20 ----------------------------- 1981-07-10 17:33:39.5712+00 (1 row) Again, I'm just guessing as to what your START_TIME and STOP_TIME values = mean. You should ask whomever gave you the CSV files. Hope this helps, Ed