Scalabium Software

SMExport advertising
Knowledge for your independence'.
Home Delphi and C++Builder tips

#124: extended DayOfWeek function

As you know, the default DayOfWeek function from SysUtils unit returns the day of week for some date. But in this function uses the Sunday as first day of the week and the Saturday as the seventh.

In some countries this function is not useful because the first day of the week is a Monday instead Sunday. The function below can be used in this case:

For example, in code below you'll see how to add in TListView component the rows for each attachment file:

function DayOfWeekMon2Sun(dtDate: TDateTime): Integer;
  StartOfWeek: Integer = 2;
  Result := (DayOfWeek(dtDate) - StartOfWeek + 7) mod 7 + 1;

I wrote this function a lot of time ago when I started the development of scheduler program and wanted to add a possibility to define a custom timesheet (like in MS Outlook).

I hope that this function will be useful for you too.

PS: as you see, I used the const value (StartOfWeek) as shift. So if your country use the some other order in days of the week, you can change this const value.

Published: August 30, 2001

See also
DBExport tools
Paradox to MS Access converter
Paradox Password Recovery
Excel Web-stream
Paradox ActiveX
ExcelFile Viewer
SMMsg suite
Viewer for MS Outlook Messages
ABA Spreadsheet Convert

Contact to webmaster


Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2021, Scalabium Software. All rights reserved.

SMExport/SMImport suites