Autor Beitrag
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Di 30.09.03 09:47 
Moin,

ich habe ein Datum, z.B. 30.09.2003. Nun brauche ich eine Funktion, die mir Anhand des Datums den Montag und den Sonntag der Woche zurückliefert, also 29.09.2003 und 05.10.2003.

Gibts so was?

Sorry, ich steh heute echt am Schlauch.

Viele Grüße,

Matthias

_________________
Ha! Es compiliert! Wir können ausliefern!
Licki
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 132

Knoppix, Win 95, Win 2000, Win NT, Win 98, Win XP
Delphi 3
BeitragVerfasst: Di 30.09.03 10:08 
Du kannst doch einfach vom aktuellen Datum soviele Tage abziehen, bis du den gewünschten Tag erreicht hast.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 30.09.03 10:13 
klar geht das:
probier mal StartOfTheWeek und EndOfTheWeek. Guck mal in der Hilfe unter Date/Time routines nach. Da findest du alles mögliche dazu.
Evtl. muss man einen Tag drauf oder abrechnen, weiss jetzt nicht genau, welchen Tag diese Funktionen als Wochenbeginn / -ende sehen.

_________________
We are, we were and will not be.
barfuesser
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 324



BeitragVerfasst: Di 30.09.03 10:43 
StartOfTheWeek ist Montag 00:00:00.000 Uhr
EndOfTheWeek ist Sonntag 23:59:59.999 Uhr

barfuesser
neojones Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Di 30.09.03 13:51 
Hallo,

kann das sein, dass diese Funktion unter Delphi5 noch nicht verfügbar ist?

Viele Grüße,

Matthias

_________________
Ha! Es compiliert! Wir können ausliefern!
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 30.09.03 15:55 
kann sein, aber guck mal nach, was du für Date-time-Routinen da hast. Es gibt dich bestimmt Dayofweek oder dayoftheweek, oder?
Wenn du weisst, dass heute Mittwoch ist, dann kannst du doch das Ende der letzten und den Beginn der nächsten Woche ausrechnen, oder?

_________________
We are, we were and will not be.
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Mi 01.10.03 07:51 
Hallo,

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
// gibt den Montag einer beliebigen Woche zurück
function StartDerWoche(const aDatum:TDateTime):TDateTime;
var wt:Integer;
begin
  wt:=DayOfWeek(aDatum)-1;
  if (wt=0) then wt:=7;
  Result:=aDatum-wt+1;
end; // StartDerWoche


// gibt den Sonntag einer beliebigen Woche zurück
function EndeDerWoche(const aDatum:TDateTime):TDateTime;
var wt:Integer;
begin
  wt:=DayOfWeek(aDatum)-1;
  if (wt=0) then wt:=7;
  Result:=aDatum+7-wt;
end; // EndeDerWoche

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)