| Subject |
Re: date settings |
| From |
Gaetano <gaetanodd@hotmail.com> |
| Date |
Sat, 2 Jan 2021 06:20:08 +1000 |
| Newsgroups |
dbase.getting-started |
On 02/01/2021 04:04, Ken Mayer wrote:
> Not sure what you're doing, but in the command window I did:
>
> d={01/01/2021}
> ? d
> set date to ymd
> ? d
>
>
> And the results were:
>
> 01/01/2021
> 2021/01/01
>
> Which is exactly as expected.
>
> Ken
Ken,
What Mustansir is seeing is typical of YMD string interpretation in
dBase. When you recently asked a question about dates in NG.Internet, I
did a couple tests and I had a similar output with year = 2007 I think.
Now the incorrect years are 2021 or 2183 (there isn't even a "3" or an
"8" in the string, where does 2183 come from?):
If I try this with my Australian regional settings, the date string
"pairs" are always the same, the variable "a" is recognized as a DT in
all cases, but I get 3 different dates depending on the SET DATE setting
even though the date and time are non-ambiguous.
Needless to say that if you want to run this code and your setting is
MDY, you will need to adapt the SET DATE commands (add SET DMY at the
top and SET DATE to MDY at bottom).
clear
?"-------- with DMY --------"
d="2020-12-15 17:10"
a={&d}
?"Type of 'a'="+type("a")
?a.tostring()
d="15-12-2020 17:10"
a={&d}
?"Type of 'a'="+type("a")
?a.tostring()
?
?
?"-------- with MDY --------"
set date to MDY
d="2020-12-15 17:10"
a={&d}
?"Type of 'a'="+type("a")
?a.tostring()
d="15-12-2020 17:10"
a={&d}
?"Type of 'a'="+type("a")
?a.tostring()
?
?
?"-------- with YMD --------"
set date to YMD
d="2020-12-15 17:10"
a={&d}
?"Type of 'a'="+type("a")
?a.tostring()
d="15-12-2020 17:10"
a={&d}
?"Type of 'a'="+type("a")
?a.tostring()
//reset date to original format
set date to DMY
------------------ the output is:-------------------
-------- with DMY --------
Type of 'a'=DT
Fri Jun 11 17:10:00 E. Australia Standard Time 2021
Type of 'a'=DT
Tue Dec 15 17:10:00 E. Australia Standard Time 2020
-------- with MDY --------
Type of 'a'=DT
Sun Apr 13 17:10:00 E. Australia Standard Time 2183
Type of 'a'=DT
Sun Mar 14 17:10:00 E. Australia Standard Time 2021
-------- with YMD --------
Type of 'a'=DT
Tue Dec 15 17:10:00 E. Australia Standard Time 2020
Type of 'a'=DT
Fri Jun 11 17:10:00 E. Australia Standard Time 2021
|
|