PDA

Ver la Versión Completa : Algoritmo de FECHA


bustio
11-01-2004, 05:20:50
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)

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

saludos