Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Algoritmo de FECHA (https://www.clubdelphi.com/foros/showthread.php?t=6507)

bustio 11-01-2004 05:20:50

Algoritmo de FECHA
 
Hola y saludos desde La Habana...
Necesito un algoritmo que me permita restringir el uso de un TDateTimePicker a la semana en curso..para hacer reservaciones en sus dias, pero solo de la semana en curso.
Ya se que con el MinDate puedo ponerle la fecha actual para restringirlo al dia actual(TDateTimePicker.MinDate := Now - 1) pero como hacer esto para que TDateTimePicker.MaxDate := Domingo de esa semana????.
Las reservaciones que necesito hacer sus fechas deben ir desde el dia actual hasta el domingo de esa semana, y que lo incluya, por supuesto. Al llegar el lunes de la semana siguiente necesito que ese proceso se repita.
De veras estoy perdido con el TDateTimePicker, y a pesar de que ya he intentado hacerlo varias veces no me trabaja...
Ademas, deseo FELICITAR a todos los que tengan que ver con esta Web.... de veras que estan fuera de LIGA.. dicho en buen Cubano..
GRACIAS

Lepe 11-01-2004 20:32:23

DayOfTheWeek(date:tdatetime)

Returns the day of the week represented by a TDateTime value.

Unit

DateUtils

Category

date/time routines

function DayOfTheWeek(const AValue: TDateTime): Word;

Description

Call DayOfTheWeek to obtain the day of the week represented by a specified TDateTime value. DayOfTheWeek returns a value between 1 and 7, where 1 indicates Monday and 7 indicates Sunday.

Note: DayOfTheWeek is ISO 8601 compliant (where Monday is considered the first day of the week). To obtain the day of the week where Sunday is considered the first day of the week, use the DayOfWeek function instead.
Tip: To make the return value more readable, use the Day of week constants.

Si dayoftheweek(now) te dice que es el 3 (Miercoles)
Código:

  datepicker1.maxdate:= now+ (7-dayoftheweek(now))
saludos


La franja horaria es GMT +2. Ahora son las 10:09:31.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi