Re: Problem with date
Posted: Wed Aug 20, 2025 4:16 pm
See the dictionary entry for "useSystemDate"
Questions and answers about the LiveCode platform.
https://forums.livecode.com/
scholars estimate that roughly 40-50 distinct calendar systems are still actively used today in some capacity
There must be something in those images I'm not noticing.
Code: Select all
if fld "dateready" is 3 then
set the itemdelimiter to "/"
put word 1 of fld "startday" into sday
put word 1 of fld "startyr" into syr
put word 1 of fld "startmth" into smth
put sday & "/" & smth & "/" & syr into tdate
put sday & "/" & smth & "/" & syr into tdate2
convert tdate2 to seconds
#answer tdate2
#convert tdate2 to system date
#convert tdate2 to seconds
put tdate2 into fld "date3"
show fld "announce81"
put "The start date of the current business trading year is" & CR & tdate into fld "announce81"
convert the date to seconds
put it into date2
put it into fld "date2"
put fld "date2" - fld "date3" into fld "temp1"
put 60*60*24*365 into date4
put 60*60*24*365 into fld "date4"
if fld "temp1" > fld "date4" then
put "nogo" into fld "temp2"
end if
if fld "temp2" is "nogo" then
answer "That date is more than a year ago, so cannot refer to the current year. Try again"
hide fld "announce81"
put empty into fld "temp2"
put empty into fld "temp1"
put empty into fld "date2"
put empty into fld "date3"
put empty into fld "date4"
exit mouseup
end if
Code: Select all
fld "dateready" is 3 thenCode: Select all
fld "dateready" contains 3 thenCode: Select all
fld "dateready" is 3Code: Select all
fld "dateready" = 3Code: Select all
if fld "dateready" is 3 then
set the itemdelimiter to "/"
put word 1 of fld "startday" into sday
put word 1 of fld "startyr" into syr
put word 1 of fld "startmth" into smth
put smth & "/" & sday & "/" & syr into tdate2
put sday & "/" & smth & "/" & syr into tdate
convert tdate from system date to long english date
convert tdate2 to seconds
put tdate2 into fld "date3"
show fld "announce81"
put "The start date of the current business trading year is" & CR & tdate into fld "announce81"
convert the date to seconds
put it into date2
put it into fld "date2"
put fld "date2" - fld "date3" into fld "temp1"
put 60*60*24*365 into date4
put 60*60*24*365 into fld "date4"
if fld "temp1" > fld "date4" then
put "nogo" into fld "temp2"
end if
if fld "temp2" is "nogo" then
answer "That date is more than a year ago, so cannot refer to the current year. Try again."titled field "fieldboxtitle" of cd "template1"
hide fld "announce81"
put empty into fld "temp2"
put empty into fld "temp1"
put empty into fld "date2"
put empty into fld "date3"
put empty into fld "date4"
exit mouseup
end if
if fld "temp1" < 0 then
answer "That date is in the future, so cannot be the start date of the current year. Try again."titled field "fieldboxtitle" of cd "template1"
hide fld "announce81"
put empty into fld "temp2"
put empty into fld "temp1"
put empty into fld "date2"
put empty into fld "date3"
put empty into fld "date4"
exit mouseup
end if
end ifCode: Select all
...
convert tdate from system date to long english date
...I'd be a bit careful where you use that phrase.A free-born Englishman
As a fellow citizen of the formerly Great Britain:CAsba wrote: Thu Aug 21, 2025 3:49 pm I am a native of the United Kingdom of GREAT (get that ?, GREAT) Britain.
Code: Select all
on mouseUp
set the useSystemDate to true
put field "fldDate" into tDate
if tDate is not a date then
answer "The field contents do not match the date format according to the regional settings of this computer" -- or you're on Windows and the year you've input is prior to 1970, stupid, stupidly unforgiveable bug
else
convert tDate to seconds
answer tDate
end if
end mouseUp