Page 1 of 1
How to get the name of the day only? (Without all the full date but only the day)
Posted: Tue Mar 22, 2022 4:36 pm
by liveCode
How to get the name of the day only? (Without all the full date but only the day)
Re: How to get the name of the day only? (Without all the full date but only the day)
Posted: Tue Mar 22, 2022 4:42 pm
by jmburnod
Hi,
The long date is what you looking for
return "tuesday, march 22,2022"
Best
Jean-Marc
Re: How to get the name of the day only? (Without all the full date but only the day)
Posted: Tue Mar 22, 2022 4:52 pm
by liveCode
But I want him to return only the day without the date for example if today is Tuesday then he will return "Tuesday"
Re: How to get the name of the day only? (Without all the full date but only the day)
Posted: Tue Mar 22, 2022 4:54 pm
by jmburnod
Code: Select all
put item 1 of the long date into tDay
put tDay
Re: How to get the name of the day only? (Without all the full date but only the day)
Posted: Tue Mar 22, 2022 4:57 pm
by liveCode
Thank you.
Re: How to get the name of the day only? (Without all the full date but only the day)
Posted: Tue Mar 22, 2022 5:08 pm
by richmond62
This is the moment to point out that item delimiters
(unless otherwise specified) are commas in LiveCode.
So, knowing that, it is very easy to chop up information into useful pieces, so,
for instance from the long date:
item one is the day,
item 2 is the date and month,
and item 3 is the year.
Re: How to get the name of the day only? (Without all the full date but only the day)
Posted: Tue Mar 22, 2022 6:18 pm
by dunbarx
What everyone said.
When Jean-Marc gave you the output of the long date, and you did not immediately see that you could very easily extract "Tuesday" from that string, means you need to learn, as soon as possible, about how LiveCode handles text, especially regarding what are known as "chunks". Chunks are simply parts of a body of text, separated in certain ways. Words are separated by spaces, lines by returns, and others.
Richmond tells you that you can deal with text by parsing into "items", usually delimited by commas. Know that items can be delimited by any string, such as:
Code: Select all
cat,dog,mouse --comma is the delimiter
cat=dog=mouse --"=" is the delimiter
catXXXXdogXXXXmouse --"XXXX" is the delimiter
In any of the above, if you set the itemDelimiter to the string shown, then item 2 of any of the above lines would give you "dog".
Craig
Re: How to get the name of the day only? (Without all the full date but only the day)
Posted: Tue Mar 22, 2022 7:39 pm
by liveCode
Thank you very much I learned a lot from you