function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sarvesh001sarvesh001 

How to get sundays from input month and year

Hi,
I want to find the the all sunday in a month based on input month name and  year.

Can anyone help me out for this.


Regards,
Sarevsh

 
ra811.3921220580267847E12ra811.3921220580267847E12
Hi,
VF Page:
<apex:page controller="add" docType="html-5.0" id="thePage">
<script>
  function printalert()
  {
  alert('hello');
  
  var today=document.getElementById('thePage:theForm:dt1').value;
  alert(today);
  var dat = new Date(today);
var y = dat.getFullYear();
        var m = dat.getMonth() + 1;
        var days = new Date( y,m,0 ).getDate();
        var sundays = [ (8 - (new Date( m + '/01/' + y ).getDay())) % 7 ];

        for ( var i = sundays[0] + 7; i < days; i += 7 ) {
            sundays.push( i );

        }
    alert(sundays);
 
  }
  
  
  </script>
  <apex:form id="theForm">
 
Date: <apex:input type="date" value="{!dat}" id="dt1"/>
  <apex:commandButton value="click me" onclick="printalert();return false"/>
 
  </apex:form>
</apex:page>

controller:

public class add {

    public String dat { get; set; }

    public String tex1 { get; set; }
}
sarvesh001sarvesh001
Hi@  rameshballem811

I want to find the all sunday for given month and year.



Thanks,