Tuesday, June 15, 2021

Re: Find number of days between two date excluding weekend days and display the number in text field

You need to hit an ajax request to the server on the api when there is change event on the field from were you are taking the second date as input send both first and second date as data in post request to the backend and send the days as response 

On Tuesday, 15 June 2021 at 15:57:07 UTC+5:30 eugenet...@gmail.com wrote:
Dear NA,

I accomplished this with numpy. How can I get the value (difference between the two dates) when I select the second date for example in the text field? I know Javascript  can be used but how?

On Tue, 15 Jun 2021 at 11:14, Nikeet NA <nik...@exiverlabs.co.in> wrote:
You need to loop through the dates maintain a count variable get the weekday for every datetime object with date.weekday() exclude as per your need for days you dont want to count.

On Tuesday, 15 June 2021 at 11:30:21 UTC+5:30 eugenet...@gmail.com wrote:
Team,

I have date1 and date2 fields. I am able to calculate number of days between the two dates using relativedelta as shown below:

date1 = datetime.datetime.strptime(str(end_date), '%Y-%m-%d')
date2 = datetime.datetime.strptime(str(start_date), '%Y-%m-%d')
r = relativedelta.relativedelta(date1, date2)
n_days=r.days
What I want now is calculating the days but excluding weekends days. Again I want to pick the second date and get the number of days (date2-date1) in the text field directly.

Please help.

Thanks
--
Eugene


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/16ba7533-93ba-4925-9f93-e430d7128342n%40googlegroups.com.


--
TUYIZERE Eugene

Msc Degree in Mathematical Science

African Institute for Mathematical Sciences (AIMS Cameroon)
Crystal Garden-Lime, Cameroon


Bsc in Computer Science

UR-Nyagatare Campus

Email: eugene....@aims-cameroon.org
           eugenet...@gmail.com

Tel: (+250) 7 88 26 33 38, (+250) 7 22 26 33 38

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f90effb8-2ba5-49fa-b340-cd8862d3e039n%40googlegroups.com.

No comments:

Post a Comment