Discussion:
Getting the weekday name
Peter Haworth
2010-11-13 21:44:59 UTC
Permalink
I'm using the datetimetoJulian function in Sarah's great datetime
stack as part of a way to get the alpha weekday name. The words in
Sarah's stack say that it's possible to get the day number of the week
by taking the remainder of dividing the Julian days by 7 but when I do
that, I consistently get a day number that is 2 less than it should be
- that's assuming of course that day 1 would be Sunday.

I can always just add 2 to the day number but wondering if anyone
knows why this would happen?

Pete Haworth
Dick Kriesel
2010-11-13 22:42:05 UTC
Permalink
Post by Peter Haworth
I'm using the datetimetoJulian function in Sarah's great datetime
stack as part of a way to get the alpha weekday name. The words in
Sarah's stack say that it's possible to get the day number of the week
by taking the remainder of dividing the Julian days by 7 but when I do
that, I consistently get a day number that is 2 less than it should be
- that's assuming of course that day 1 would be Sunday.
I can always just add 2 to the day number but wondering if anyone
knows why this would happen?
Pete Haworth
Hi, Pete. Might your task be easier using "dateItems" as this example does?

function dayOfWeek tDate
convert tDate to dateItems
return item last item of tDate of \
"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday"
end dayOfWeek

-- Dick
Peter Haworth
2010-11-13 22:46:43 UTC
Permalink
That sounds simpler! I've never used convert and dateitems - what
format would tdate have to be in?

Pete Haworth
Post by Dick Kriesel
Post by Peter Haworth
I'm using the datetimetoJulian function in Sarah's great datetime
stack as part of a way to get the alpha weekday name. The words in
Sarah's stack say that it's possible to get the day number of the week
by taking the remainder of dividing the Julian days by 7 but when I do
that, I consistently get a day number that is 2 less than it should be
- that's assuming of course that day 1 would be Sunday.
I can always just add 2 to the day number but wondering if anyone
knows why this would happen?
Pete Haworth
Hi, Pete. Might your task be easier using "dateItems" as this
example does?
function dayOfWeek tDate
convert tDate to dateItems
return item last item of tDate of \
"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday"
end dayOfWeek
-- Dick
_______________________________________________
use-revolution mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-revolution
J. Landman Gay
2010-11-13 22:46:47 UTC
Permalink
I'm using the datetimetoJulian function in Sarah's great datetime stack
as part of a way to get the alpha weekday name. The words in Sarah's
stack say that it's possible to get the day number of the week by taking
the remainder of dividing the Julian days by 7 but when I do that, I
consistently get a day number that is 2 less than it should be - that's
assuming of course that day 1 would be Sunday.
I can always just add 2 to the day number but wondering if anyone knows
why this would happen?
Just curious, do you really need Julian dates? If you already have an
existing date in a valid format, it should convert to the long date
successfully. That has the alpha day of the week as the first item.
--
Jacqueline Landman Gay | ***@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Peter Haworth
2010-11-13 22:55:25 UTC
Permalink
The dates are coming from an SQL database, so they are in yyyy-mm-dd
format - will that work or do I need to convert them to some other
dat? I already have a function that converts the SQL dates to the
external format mm/dd/yy if that would work better.

Pete Haworth
Post by J. Landman Gay
I'm using the datetimetoJulian function in Sarah's great datetime stack
as part of a way to get the alpha weekday name. The words in Sarah's
stack say that it's possible to get the day number of the week by taking
the remainder of dividing the Julian days by 7 but when I do that, I
consistently get a day number that is 2 less than it should be - that's
assuming of course that day 1 would be Sunday.
I can always just add 2 to the day number but wondering if anyone knows
why this would happen?
Just curious, do you really need Julian dates? If you already have
an existing date in a valid format, it should convert to the long
date successfully. That has the alpha day of the week as the first
item.
--
HyperActive Software | http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-revolution
J. Landman Gay
2010-11-14 20:35:35 UTC
Permalink
Post by Peter Haworth
The dates are coming from an SQL database, so they are in yyyy-mm-dd
format - will that work or do I need to convert them to some other dat?
I already have a function that converts the SQL dates to the external
format mm/dd/yy if that would work better.
You need to use your conversion function to change the dates to mm/dd/yy
format. Then use the convert command to convert that to the long date,
and lift out the first item which will be the weekday name.
--
Jacqueline Landman Gay | ***@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Peter Haworth
2010-11-15 00:47:37 UTC
Permalink
Thanks. I forgot that I have been using the SQLite strftime function
to do all my date formatting/calculations so I think I'll just use that.

Pete Haworth
Post by J. Landman Gay
Post by Peter Haworth
The dates are coming from an SQL database, so they are in yyyy-mm-dd
format - will that work or do I need to convert them to some other dat?
I already have a function that converts the SQL dates to the external
format mm/dd/yy if that would work better.
You need to use your conversion function to change the dates to mm/
dd/yy format. Then use the convert command to convert that to the
long date, and lift out the first item which will be the weekday name.
--
HyperActive Software | http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
Please visit this url to subscribe, unsubscribe and manage your
http://lists.runrev.com/mailman/listinfo/use-revolution
Continue reading on narkive:
Loading...