DDH Software, Inc Making a big world smaller

Return to Knowledgebase Home
How can I Show the day of the week, based on a Date type field.
Product: General HanDBase TopicArticle Number: 196Creation Date: 08/28/2002

Showing the day of the week, based on a Date type field.

Currently, HanDBase does not include a day of the week (Monday, Tuesday, Wednesday, ) field type. It also does not include a way to convert the output of the Date field (MM/DD/YY) into a day of the week.

A suggested work-around for that is to calculate the day of the week using the Calculated field type. The result will be a number, instead of the days name. The database author can then take that number and convert it to a name (with a Conditional field type or a Relationship field type) or do some other processing.

Result Day of the Week
0 Sunday
1 Monday
2 Tuesday
3 Wednesday
4 Thursday
5 Friday
6 Saturday

The formula is pretty straightforward:

(Fn - 2) - (Floor((Fn - 2) / 7) * 7)

(Where 'Fn' is the field number that contains the Date type.)

The formula works from the fact that that dates are handled as an integer number (i.e. today is 36034). So we divide by the number of days in a week, the modulus of the operation is the position of the day in the week, since day 1 (01/02/1904) is in the middle of the week we do an adjustment of -2 to get Sunday to be 0.

You may download an example database that shows how this is done in practice in the Gallery.

This article has been viewed 1 times.

Return to Knowledgebase Home