String to date
Hello. Newbie to Rebol/Red. How can I convert "230919" to date that represents 2023/09/19? My plan is to count days in-between today and the date represented by the string.
posted by: mbenam 8-Oct-2022/23:30:33-7:00
If your string is always "YYMMDD" then you can just copy out the various parts:
make date! reduce [
2000 + to integer! copy/part mystring 2
to integer! copy/part skip mystring 2 2
to integer! copy/part skip mystring 4 2
posted by: Chris 9-Oct-2022/11:50:57-7:00
This is great! Need to learn the keyword "make". Thank you.
posted by: mbenam 9-Oct-2022/12:17:01-7:00
insert at x 1 "20"
insert at x 5 "/"
insert at x 8 "/"
posted by: Nick 9-Oct-2022/12:40:20-7:00
This seems more elegant, Nick. However, on Red had to use load command instead of to-date.
posted by: mbenam 9-Oct-2022/13:28:44-7:00