Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Hi all,
Trying to get the long date from user-entered year/month/day, it does not convert to long date.
My code is
on mouseup
set the itemDelimiter to "/"
put field "startyr" & "/" into field "fieldannounce2"
set the itemDelimiter to "/"
put field "startmth" & "/" after field "fieldannounce2"
set the itemDelimiter to "/"
put field "startday" after field "fieldannounce2"
set the itemDelimiter to "/"
put fld "fieldannounce2" into tDate
set the itemDelimiter to "/"
convert tDate to DATEITEMS
set the itemDelimiter to "/"
convert tDate to date
answer tDate
convert tdate to long date
answer tDate
put tdate into field "formatted date"
convert field "formatted date" to long date
end mouseup
Neither answer gives the long date, nor does 'formatted date'.
Any ideas, please ?
on mouseup
## ITEMDELIMITER will last for the complete handler, so you only need to set it ONCE!
## However it is not used in this handler so you can leave it out here completely!
## set the itemDelimiter to "/"
## Wrong ORDER for (english) date!!!
## yyyy/mm/dd does not work in LC!
# put field "startyr" & "/" into field "fieldannounce2"
# put field "startmth" & "/" after field "fieldannounce2"
# put field "startday" after field "fieldannounce2"
## the date in LC -> mm/dd/yy
put field "startmth" & "/" into field "fieldannounce2"
put field "startday"& "/" after field "fieldannounce2"
put field "startyr" after field "fieldannounce2"
put fld "fieldannounce2" into tDate
## You have to tell LC that is is a date now!
## However no need to to do this extra conversion!
## convert tDate from date to DATEITEMS
## convert tDate to date
## answer tDate
## See above, LC needs to know what to do:
convert tDate from date to long date
put tDate into field "formatted date"
## Not neccessary, since you do not do anything with the converted date
## convert field "formatted date" to long date
end mouseup
on mouseup
put field "startmth" & "/" into field "fieldannounce2"
put field "startday"& "/" after field "fieldannounce2"
put field "startyr" after field "fieldannounce2"
put fld "fieldannounce2" into tDate
convert tDate from date to long date
put tDate into field "formatted date"
end mouseup