strftime("%Y", "-1234-01-01") returns -123

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

strftime("%Y", "-1234-01-01") returns -123

Tanaka Akira
Hi.
I found a doubtful behavior of strftime("%Y").

strftime("%Y", "-1234-01-01") returns -123 but
I feel it should be -1234.
(But it can be error because the manual describes "%Y year: 0000-9999".)

% ./sqlite3
SQLite version 3.29.0 2019-07-10 17:32:03
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> SELECT strftime("%Y", "-1234-05-06");
-123
sqlite>
% ./sqlite3 -version
3.29.0 2019-07-10 17:32:03
fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88bfa6

I built sqlite3 from sqlite-autoconf-3290000.tar.gz downloaded today.

% ls ..
sqlite-autoconf-3290000  sqlite-autoconf-3290000.tar.gz
--
Tanaka Akira
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: strftime("%Y", "-1234-01-01") returns -123

Richard Hipp-3
On 7/16/19, Tanaka Akira <[hidden email]> wrote:
> Hi.
> I found a doubtful behavior of strftime("%Y").
>
> strftime("%Y", "-1234-01-01") returns -123

Perhaps you overlooked the following paragraph from the documentation:

"These functions only work for dates between 0000-01-01 00:00:00 and
9999-12-31 23:59:59 (julian day numbers 1721059.5 through 5373484.5).
For dates outside that range, the results of these functions are
undefined."

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] strftime("%Y", "-1234-01-01") returns -123

Hick Gunter
In reply to this post by Tanaka Akira
You should be using single quotes for string delimiters. Additionally, you are seeing right handed truncation of a 5 character string in a 4 character field

asql> select strftime('%Y','-0123-04-05');
strftime('%Y','-0123-04-05')
----------------------------
-123


-----Original Message-----
From: sqlite-users [mailto:[hidden email]] On Behalf Of Tanaka Akira
Sent: Dienstag, 16. Juli 2019 14:08
To: [hidden email]
Subject: [EXTERNAL] [sqlite] strftime("%Y", "-1234-01-01") returns -123

Hi.
I found a doubtful behavior of strftime("%Y").

strftime("%Y", "-1234-01-01") returns -123 but I feel it should be -1234.
(But it can be error because the manual describes "%Y year: 0000-9999".)

% ./sqlite3
SQLite version 3.29.0 2019-07-10 17:32:03 Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> SELECT strftime("%Y", "-1234-05-06");
-123
sqlite>
% ./sqlite3 -version
3.29.0 2019-07-10 17:32:03
fc82b73eaac8b36950e527f12c4b5dc1e147e6f4ad2217ae43ad82882a88bfa6

I built sqlite3 from sqlite-autoconf-3290000.tar.gz downloaded today.

% ls ..
sqlite-autoconf-3290000  sqlite-autoconf-3290000.tar.gz
--
Tanaka Akira
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0

May be privileged. May be confidential. Please delete if not the addressee.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: strftime("%Y", "-1234-01-01") returns -123

Tanaka Akira
In reply to this post by Richard Hipp-3
2019-07-16 21:26 Richard Hipp <[hidden email]>:

> Perhaps you overlooked the following paragraph from the documentation:
>
> "These functions only work for dates between 0000-01-01 00:00:00 and
> 9999-12-31 23:59:59 (julian day numbers 1721059.5 through 5373484.5).
> For dates outside that range, the results of these functions are
> undefined."

I see.  Thank you.
--
Tanaka Akira
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users