Page 1 of 2
Problem with date
Posted: Wed Aug 20, 2025 12:54 pm
by CAsba
Hi again,
My euphoria in solving the last date problem was shortlived. I discovered by chance that the convert to seconds command was intermittently failing to work. I isolated the problem in a substack, consisting of two fields, field, and field2, and a button. The button code is
Code: Select all
convert fld "field" to seconds
convert fld "field2" to seconds
In fld "field" I typed 24/3/25 and in fld "field2" I typed 3/3/25.
Only fld "field2" converted.
Please try this and tell me if this failure is universal or, as usual, down to something I am doing wrong.
Re: Problem with date
Posted: Wed Aug 20, 2025 2:07 pm
by Klaus
I can reproduce this! No idea if this is a bug or a freature.
In the meantime use a variable and write it back after conversion:
Code: Select all
...
put fld "field" into tSecs1
convert tSecs1 to seconds
put tSecs1 into fld "field"
## Same for fld "field2"
...
Best
Klaus
Re: Problem with date
Posted: Wed Aug 20, 2025 2:33 pm
by dunbarx
CAsba, Klaus.
The "dates" in the two fields are of different formats. Of course they cannot be conceptually mixed in the simplistic way CAsba tried.
Craig
Re: Problem with date
Posted: Wed Aug 20, 2025 2:50 pm
by Klaus
Ah, yes, my fault!
@CAsba
When using "convert" you need to supply a VALID format.
If you don't specify a format, LC thinks you are using a ENGLISH date (mm/dd/yy)
and 24/3/25 is NOT, so it won't get converted.
I thought you already got a hint about SYSTEMDATE in another thread?
Best
Klaus
Re: Problem with date
Posted: Wed Aug 20, 2025 2:58 pm
by CAsba
Thinking about this, it occurred to me that maybe, to convert, the date to be converted should be in the american format. I'll try playing with that.
Re: Problem with date
Posted: Wed Aug 20, 2025 3:00 pm
by CAsba
Hi Klaus,
I didn't get your input until after I sent mine !
Two ships in the night..
Re: Problem with date
Posted: Wed Aug 20, 2025 3:01 pm
by richmond62
ENGLISH date (mm/dd/yy)
That is an American date, and not an English one.
AND if you ask for the date:
you will get whatever is the format of the end-user's computer.
If you do this:
you will be able to use that to work out what format the end-user is using.
For instance, my system uses the European date format and returns:
%#d.%m.%y
Then you'll have to play various funny games depending on whether:
1. The month has 28,29,30, or 31 days.
2. Whether the preceding year had 365 or 366 days in it.
-
Re: Problem with date
Posted: Wed Aug 20, 2025 3:09 pm
by Klaus
And how does an ENGLISH date look like?
Re: Problem with date
Posted: Wed Aug 20, 2025 3:14 pm
by richmond62
There is some confusion as today, in the English format is:
20/08/2025
while the American format is:
08/20/2025
But for some ODD reason:
-
-
inwith LiveCode 'english' specifies the American date format.
viewtopic.php?t=21655
in a perfect world (?) one could do this sort of thing (pseudocode):
Note: The english keyword is implemented internally as a property and appears in the propertyNames. However, it cannot be used as a property in an expression, nor with the set command.
Re: Problem with date
Posted: Wed Aug 20, 2025 3:19 pm
by Klaus
AHA!
Thank you for the explanation, so I got it wrong the last 69 years!

Re: Problem with date
Posted: Wed Aug 20, 2025 3:25 pm
by CAsba
Hi Klaus,
I don't think I picked up a hint about systemdate in a previous thread..
I'm now trying to find how to change 24/3/25 into a systemdate (?) other than writing some complex script to move the dateitems of it to new positions.
Re: Problem with date
Posted: Wed Aug 20, 2025 3:30 pm
by CAsba
Klaus,
I forgot to say, the code you sent me didn't do it.
Re: Problem with date
Posted: Wed Aug 20, 2025 3:49 pm
by Klaus
CAsba wrote: ↑Wed Aug 20, 2025 3:30 pm
Klaus,
I forgot to say, the code you sent me didn't do it.
Yes, because we used an invalid (non english) date -> 24/3/25
Code: Select all
...
convert fld "field" FROM SYSTEM DATE to seconds
convert fld "field2" FROM SYSTEM DATE to seconds
...
Will work as long as there ARE in fact system dates in the fields.
What country are you living in?
And how did the date get into the field? Did your user enter it or are you using a script?
If the latter please show the script.
Re: Problem with date
Posted: Wed Aug 20, 2025 3:50 pm
by richmond62
Code: Select all
on mouseUp
put "1/1/08 3:06 AM" into theTime
convert theTime to seconds
put theTime
end mouseUp
Re: Problem with date
Posted: Wed Aug 20, 2025 3:57 pm
by richmond62
Here's a fairly silly stack that will convert your system date to what LiveCode erroneously calls the 'English' date:
-