Adolfo,

I found by testing that your code does not work for dates prior to 1901. It's also pretty complex code, in my opinion.

This code works for any month from October 1752 and beyond. (Prior to 10/1752, leap years were not observed, and 12 days were actually removed from September in 1752 to adjust the calendar.) The code could be adjusted to compensate for this, but that was more than I wanted to do - how often would we need a calendar prior to 1752 anyway? ;\)
 Code:
; DisplayCalMonth(date)
; Glenn Barnas
; Displays a calendar month, highlighting a specific day
; Accepts a single date argument in the format YYYY/MM/DD
;
Function DisplayCalMonth($_MyDate)

  Dim $_MName					; Array of month names
  Dim $_Offset, $_LOff				; Left offset count, string of spaces
  Dim $_aMyDate					; Array of date values
  Dim $_DCurr, $_DFirst, $_DLast		; Defined day of month, first weekday, last day of month
  Dim $_Header					; header string - Month YYYY
  Dim $_Tag, $_Day				; Loop counter, Day index

  ; Month name array
  $_MName = 'January','February','March','April','May','June','July','August','September','October','November','December'

  ; Left offset is 3 spaces, up to 40 are permitted
  $_Offset = 12
  $_LOff = Left('                                        ', $_Offset)

  ; Split the supplied date value into an array
  $_aMyDate = Split($_MyDate, '/')


  $_dCurr = $_aMyDate[2]			; save the defined day of the month for later reference
  $_aMyDate[2] = '1'				; Change supplied date to reference the first day of the month


  ; Determine first weekday (0=Sunday)
  ; Use TimeConvert to return cTime, divide by seconds/day to determine days, offset by 4 and use mod for a 0-6 DOW value
  $_DFirst = ((TimeConvert(Join($_aMyDate, '/') + ' 00:00:00', 0) / 86400)) Mod 7


  ; Get number of days in the current month - change to first of next month and subtract 1 day
  ; Then get the Day portion. Increment the year if we're in December!
  If Val($_aMyDate[1]) = 12
    $_aMyDate[0] = Val($_aMyDate[0]) + 1
    $_aMyDate[1] = 1
  Else
    $_aMyDate[1] = Val($_aMyDate[1]) + 1
  EndIf


  ; timeConvert date to cTime, subtract 1 day in seconds, and convert back to YYYY/MM/DD format, trim time
  $_DLast = Split(Split(TimeConvert(TimeConvert(Join($_aMyDate, '/') + ' 00:00:00', 0) - 86400, 0), '/')[2], ' ')[0]

  ; Create the header - format is "Month Year" plus an appropriate left offset
  $_Header = $_MName[Val($_aMyDate[1]) - 2] + ' ' + $_aMyDate[0]
  $_Header = Left('                    ', $_Offset + ((28 - Len($_Header)) / 2)) + $_Header


  ; Display the calendar for the defined month, highlighting the specific day
  $_Header ?
  $_LOff COLOR w+/b ' S   M   T   W   T   F   S ' COLOR w+/n

  $_Tag = 0					; loop control
  $_Day = 1					; day value
  While $_Tag >= 0
    If $_Tag <= $_DFirst			; has first day occurred?
      '    '					; if not, print blank entry
    Else
      If $_Day = $_DCurr COLOR y+/r EndIf	; highlight current day
      Right('   ' + CStr($_Day), 3) ' '		; otherwise print formatted day entry
      $_Day = $_Day + 1				; and increment day count
      COLOR w+/n				; restore color
    EndIf

    If $_Tag Mod 7 = 0 @CRLF $_LOff EndIf	; next line, then print offset

    $_Tag = $_Tag + 1
    If $_Day > $_DLast $_Tag = -1 EndIf		; close the loop when we display the last day
  Loop

  ? ?

EndFunction


I'm not particularly fond of UDFs that perform any kind of output, but this is kind of an exception - I wrote this as a UDF so multiple calendars can be easily tested/displayed.

DisplayCalMonth('1900/1/1')
DisplayCalMonth('1864/4/14')
DisplayCalMonth('2007/6/5')

Glenn
_________________________
Actually I am a Rocket Scientist! \:D