The rdayofweek() function

The rdayofweek() function returns the day of the week as an integer value for an internal DATE.

Syntax

mint rdayofweek(jdate)
   int4 jdate;
jdate
The internal representation of the date.

Return codes

0
Sunday
1
Monday
2
Tuesday
3
Wednesday
4
Thursday
5
Friday
6
Saturday

Example

The demo directory contains this sample program in the rdayofweek.ec file.
/*
   * rdayofweek.ec *

   The following program accepts a date entered from the console.
*/

#include <stdio.h>

main()
{
   mint errnum;
   int4 i_date;
   char *day_name;
   char date[20];
   int x;

   static char fmtstr[9] = "mmddyyyy";

   printf("RDAYOFWEEK Sample ESQL Program running.\n\n");

   /* Allow user to enter a date */
   printf("Enter a date as a single string, month.day.year\n");
   gets(date);

   printf("\nThe date string is %s.\n", date);

   /* Put entered date in internal format */
   if (x = rdefmtdate(&i_date, fmtstr, date))
      printf("Error %d on rdefmtdate conversion\n", x);
   else
      {
      /* Figure out what day of the week i_date is */
      switch (rdayofweek(i_date))
         {
         case 0:   day_name = "Sunday";
               break;
         case 1:   day_name = "Monday";
               break;
         case 2:   day_name = "Tuesday";
               break;
         case 3:   day_name = "Wednesday";
               break;
         case 4:   day_name = "Thursday";
               break;
         case 5:   day_name = "Friday";
               break;
         case 6:   day_name = "Saturday"; 
               break;
         }
      printf("This date is a %s.\n", day_name);
      }

    printf("\nRDAYOFWEEK Sample Program over.\n\n");
}

Output

RDAYOFWEEK Sample ESQL Program running.

Enter a date as a single string, month.day.year
10.13.07

The date string is 10.13.07.
This date is a Saturday.

RDAYOFWEEK Sample Program over.