Re: JSON / ASP.NET AJAX Dates support in PostgreSQL

Поиск
Список
Период
Сортировка
От Peter J. Holzer
Тема Re: JSON / ASP.NET AJAX Dates support in PostgreSQL
Дата
Msg-id 20230414163116.ubjrzvgjtqafajcl@hjp.at
обсуждение исходный текст
Ответ на Re: JSON / ASP.NET AJAX Dates support in PostgreSQL  (Ron <ronljohnsonjr@gmail.com>)
Ответы Re: JSON / ASP.NET AJAX Dates support in PostgreSQL  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
On 2023-04-13 10:07:09 -0500, Ron wrote:
> On 4/13/23 09:44, Sebastien Flaesch wrote:
>     Is there an easy way to convert JSON data containing ASP.NET AJAX Dates
>     into PostgreSQL timestamp?
>
>     I have this kind of JSON data:
>
>     {
>         "PurchaseOrder" : "4500000000",
>         "CreationDate" : "\/Date(1672358400000)\/",
>         "LastChangeDateTime" : "\/Date(1672692813062+0100)\/"
>     }
>
>     Warning: Note the backslash before the slashes!

That's a Noop. According to RFC 8259, "\/" is the same as "/" (no idea
why they even specified that - it seems quite pointless).

>     According to JSON spec this is valid JSON and used by AJAX Date format.

It's valid JSON, but for JSON it's just a string, not a date.

Any interpretation is strictly by convention between the sender and the
receiver.


> This looks like "milliseconds since the Unix epoch:
>
> $ date -d @1672692813.062
> Mon 02 Jan 2023 02:53:33 PM CST
>
> Thus:
> select to_timestamp(cast(1672692813062 as bigint))::timestamp;

ITYM:

    select to_timestamp(1672692813062/1000.0);

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Marc Millas
Дата:
Сообщение: Re: SIze 0 in pg_stat_file, pg_stat_progress_copy
Следующее
От: "Peter J. Holzer"
Дата:
Сообщение: Re: Guidance on INSERT RETURNING order