Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello frnds,
I want to calculate no off weeks from two dates using Angularjs. I tried this my way. but its not working. please give me some example.

Thanks,
Ram.

What I have tried:

$scope.Getweek = function () {
$scope.month = $filter('date')($scope.startOfYear, 'MM');//December-November like
$scope.day = $filter('date')($scope.startOfYear, 'dd'); //01-31 like
$scope.year = $filter('date')($scope.startOfYear, 'yyyy');//2014 like
$scope.startOfYear1 = $scope.day + '/' + $scope.month + '/' + $scope.year;
$scope.ABC = ($scope.startdate - $scope.startOfYear1) / 7;
alert($scope.ABC );
};
Posted
Comments
Suvendu Shekhar Giri 1-Aug-16 3:32am    
Share some example of input and ourtput expected.
Jameel VM 1-Aug-16 17:55pm    
why do you need angular js filter for implementing this feature?
http://stackoverflow.com/questions/20587660/calculate-date-difference-in-weeks-javascript
rameshvar 2-Aug-16 5:13am    
Thanks Suvendu and Jameel.

I done this using C#.

public static int GetNumberOfWeeks(this DateTime dt, DateTime date)
{
DateTime yearStartDate = new DateTime(date.Year, 1, 1);
TimeSpan ts = date - yearStartDate;
int totalweek = ts.Days / 7;
return totalweek;
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900