The Daily Click ::. Forums ::. Klik Coding Help ::. Date Picker/Calendar Issue
 

Post Reply  Post Oekaki 
 

Posted By Message

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
28th September, 2012 at 28/09/2012 01:14:07 -

Hi all i want to restrict the choosable date in the date picker to a predetermined day of the week. For example the earliest date the user can pick is the following wednesday and then every wednesday after that.

Anyone know if this is possible??

 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
28th September, 2012 at 28/09/2012 10:13:00 -

I have partially solved this problem using a combination of the Date Picker and the Date Time Object.

Firstly you need to work out how many seconds have elapsed by your chosen day starting from Monday.

Monday = 86400
Tuesday= 172800
Wednesday=259200
Thursday=345600
Friday=432000

(For Saturday and Sunday add 86400 to the last value in the list)

Next you need to know how many seconds are in a week:

86400*7 = 604800

What I did is store the chosen day as a Global Value in seconds (Weekday in seconds)

I was unable to restrict choices to just the chosen day however i was able to set the first available date to the next occurrence of the chosen day (i.e the next wednesday)

To do this I needed to use the following formulas:

Start of Frame + WeekDay in Seconds < 604800-(day of week of( "Date & Time" )*((60*60)*24))

Set Minimum allowed date of Date Picker to - Date Add$( "Calendar Object", System Date$( "Calendar Object" ), (WeekDay in seconds-day of week of( "Date & Time" )*((60*60)*24)))

Start of Frame + WeekDay in Seconds > 604800-(day of week of( "Date & Time" )*((60*60)*24))
Set Minimum allowed date of Date Picker to - Date Add$( "Calendar Object", System Date$( "Calendar Object" ), 604800-(day of week of( "Date & Time" )*((60*60)*24))+WeekDay in seconds)

Start of Frame + Weekday in seconds = 604800-(day of week of( "Date & Time" )*((60*60)*24))-86400
Set Minimum allowed date of date picker to Date Add$( "Calendar Object", System Date$( "Calendar Object" ), 604800)


the first 2 formula mean if it is Monday the first available date is 2 days later. If it is Thursday then the next date is Wednesday the week after.

The last formula just adds a week on if it is wednesday.

Posted this just in case someone else is ever in need of a solution to this problem


 
n/a
   

Post Reply



 



Advertisement

Worth A Click