Board index » delphi » Need to get the Weekday from TDateTime

Need to get the Weekday from TDateTime

Hi

Is there some one who knows how to get the week day of a specific date?

You may answer direct to my email if you want.

Lars Rosenberg
Dymast AB, Karlstad Sweden
Lars.Rosenb...@telia.com

 

Re:Need to get the Weekday from TDateTime


Hi!

Try this function:

function DayOfWeek(Date: TDateTime): Integer;

    //Peter Glimstedt

Quote
Lars Rosenberg wrote:
> Hi

> Is there some one who knows how to get the week day of a specific date?

> You may answer direct to my email if you want.

> Lars Rosenberg
> Dymast AB, Karlstad Sweden
> Lars.Rosenb...@telia.com

Re:Need to get the Weekday from TDateTime


In article <AXvU4.7878$Za1.121...@newsc.telia.net>, "Lars Rosenberg"

Quote
<L...@Karlstad.mail.telia.com> writes:
>Is there some one who knows how to get the week day of a specific date?

DayOfWeek(Date); // returns 5 for 18 May 2000
FormatDateTime('ddd', Date); //returns 'Thu' for 18 May 2000
FormatDateTime('dddd', Date); //returns 'Thursday' for 18 May 2000

Alan Lloyd
alangllo...@aol.com

Re:Need to get the Weekday from TDateTime


JRS:  In article <20000519005913.00883.00000...@nso-ba.aol.com> of Fri,
19 May 2000 04:59:13 seen in news:alt.comp.lang.borland-delphi,

Quote
AlanGLLoyd <alangll...@aol.com> wrote:
>In article <AXvU4.7878$Za1.121...@newsc.telia.net>, "Lars Rosenberg"
><L...@Karlstad.mail.telia.com> writes:

>>Is there some one who knows how to get the week day of a specific date?

>DayOfWeek(Date); // returns 5 for 18 May 2000
>FormatDateTime('ddd', Date); //returns 'Thu' for 18 May 2000
>FormatDateTime('dddd', Date); //returns 'Thursday' for 18 May 2000

I did not see the original, because it was ECP (one group should not
IMHO exist).

There is always the simple method : (Trunc(Date)+x) mod 7 , where a
simple test will show the required value of x, depending on one's
definition of the start of the week.  Add 1 if the numbering is to be
1..7.  For Date<0, add enough "x" to make the first argument of "mod"
non-negative.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
 Web <URL: http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
 PAS, EXE in <URL: http://www.merlyn.demon.co.uk/programs/> - see 00index.txt.
 Do not Mail News to me.    Before a reply, quote with ">" or "> " (SoRFC1036)

Other Threads