Thursday, February 9, 2012

Day of week from date picker

Hi All,

today i found some use full trick to get the Day of the week from Date time picker of infopath in browser enabled.

Step 1 :

Create a Date picker control lets say FldDate.

Step 2 :
Create a Textbox control lets say FldDayOfWeek.

Step 2 :
Add following rule to the FldDate

(number(substring(., 9, 2)) + number(number(substring(., 1, 4)) - (floor((14 - number(substring(., 6, 2))) / 12))) + floor(number(number(substring(., 1, 4)) - (floor((14 - number(substring(., 6, 2))) / 12))) / 4) - floor(number(number(substring(., 1, 4)) - (floor((14 - number(substring(., 6, 2))) / 12))) / 100) + floor(number(number(substring(., 1, 4)) - (floor((14 - number(substring(., 6, 2))) / 12))) / 400) + floor((31 * number(number(substring(., 6, 2)) + 12 * (floor((14 - number(substring(., 6, 2))) / 12)) - 2)) / 12)) mod 7

set value to the FldDayOfWeek.

Step 3 :

Add another rule like
if FldDayOfWeek == 0 then set "Sunday" to FldDayOfWeek
if FldDayOfWeek == 1 then set "Monday" to FldDayOfWeek

like wise create 5 more rule for other days week.

Now all set. if you select a particular date in Date Picker control it will show you the Day (like Sunday,Monday..).



1 comment:

Unknown said...

Hey Pradipta,
i tried "Day of week from date picker of Infopath" and this trick worked perfectly. Hoping to get some more tricks like this. Wishing best of work.

Regards
Tapashi