Greetings!
Is there a simple utility or function to determine the WEEKDAY (Monday, Tuesday, Wednesday...) from a date YYYYMMDD or 'YYYY-MM-DD' ?
GETWEEKDAY '2024-10-27'
Sunday
?
Sincere thanks!
Woody
How to determine the WEEKDAY for any given date YYYY-MM-DD
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !
- Fiona|Dyalog
- Posts: 77
- Joined: Mon Apr 22, 2013 12:59 pm
Re: How to determine the WEEKDAY for any given date YYYY-MM-
The following expression will work:
For more information on ⎕DT, see https://help.dyalog.com/19.0/#Language/ ... ons/dt.htm
'Dddd' (1200⌶) 1 ⎕DT ⊂ 2024 10 27Therefore your function will work if you create the GETWEEKDAY function as follows:
GETWEEKDAY←'Dddd' (1200⌶) 1 ⎕DT ⊂ GETWEEKDAY 2024 10 27 SundayFor more information on 1200⌶, see https://help.dyalog.com/19.0/#Language/ ... tetime.htm
For more information on ⎕DT, see https://help.dyalog.com/19.0/#Language/ ... ons/dt.htm
-
- Posts: 439
- Joined: Wed Oct 01, 2008 9:39 am
Re: How to determine the WEEKDAY for any given date YYYY-MM-
Hi Woody,
1) This is a chance to remind you and everybody reading this about Adám's great website, aplcart.info
You can search for something that you want to achieve and it gives you a great APL line to do it.
If you go to aplcart.info and ask it about day of week, it gives you this expression:
(7|1⎕DT⊆) J, where J is an integer array. The result 0 means Sunday, 1 Monday and so on:
e.g.
https://aplcart.info?q=day%20of%20week
Then, you could also search for day names, combine the expressions and get to a function like Fiona's.
2) By the way, if you are using Dyalog 17.1 and do not have ⎕DT, you could do this:
Regards,
Vince
1) This is a chance to remind you and everybody reading this about Adám's great website, aplcart.info
You can search for something that you want to achieve and it gives you a great APL line to do it.
If you go to aplcart.info and ask it about day of week, it gives you this expression:
(7|1⎕DT⊆) J, where J is an integer array. The result 0 means Sunday, 1 Monday and so on:
e.g.
(7|1⎕DT⊆) 2024 10 27 0 (7|1⎕DT⊆) 2024 10 28 1 (7|1⎕DT⊆) 2024 10 29 2Here is a URL to go to aplcart.info and search for day of week:
https://aplcart.info?q=day%20of%20week
Then, you could also search for day names, combine the expressions and get to a function like Fiona's.
2) By the way, if you are using Dyalog 17.1 and do not have ⎕DT, you could do this:
4⊃2 ⎕NQ'.' 'idntodate'(2 ⎕NQ'.' 'datetoidn' 2024 10 27) 6 4⊃2 ⎕NQ'.' 'idntodate'(2 ⎕NQ'.' 'datetoidn' 2024 11 1) 4 4⊃2 ⎕NQ'.' 'idntodate'(2 ⎕NQ'.' 'datetoidn' 2024 10 28) 0Please note that the idntodate method has 0 for Monday and 6 for Sunday.
Regards,
Vince
Re: How to determine the WEEKDAY for any given date YYYY-MM-
Perfecto !
Sincere thanks.
Sincere thanks.