+ Start a Discussion
NathanSpNathanSp 

Help with visualforce fomula and embedding a date in the url

I've been working on a way to show the one day view of an embedded google calendar and have it automatically default to next thursday's date.  I've made some progress, but I can't put it all together.  Let me share with you what I've learned so far and maybe you can tell me what I'm missing.  Thanks!

 

1.  Ok, so in order to show the Day view (rather than Month or Week) you just need to add " mode=DAY&” into the iframe url.  No problem.
2.  In order to specify which day to show in the day view (instead of today) you just need to add “ dates=20100108/20100108&” into the iframe URL (that's YYYYMMDD/YYYYMMDD of whatever day you want to display)
3.  In order to get next Thursday’s date the formula field needs to look like this:

IF(MOD(TODAY() - DATE(1900, 1, 7), 7)=0,  TODAY() + 4,
  IF(MOD(TODAY() - DATE(1900, 1, 7), 7)=1, TODAY()  + 3,
    IF(MOD(TODAY() - DATE(1900, 1, 7), 7)=2, TODAY()  + 2,
     IF(MOD(TODAY() - DATE(1900, 1, 7), 7)=3, TODAY() + 1,
       IF(MOD(TODAY() - DATE(1900, 1, 7), 7)=4, TODAY() ,
         IF(MOD(TODAY() - DATE(1900, 1, 7), 7)=5, TODAY() + 6,
           IF(MOD(TODAY() - DATE(1900, 1, 7), 7)=6,TODAY() + 5, null
)))))))

4.  In order to get the date field into the correct format you can use something like this:

<apex:outputText value="{0,date,yyyyMMdd}">
<apex:param value="{!TODAY()}" />
</apex:outputText>


I need help with a few things:
1.  How to include the formula (or reference the formula in a visualforce page
2.  How to change the date into the correct format
3.  How to get the formatted date inot the url of the iframe

Any help would be much appreciated!  Thanks!