Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
2848 มุมมอง

Hi,



I'm trying to compute a field based on the difference between the date of the record creation, and the day the record has been set to certain state.


Any idea how I could do this only computing the field I want to store the value?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi Melvin,

You can create a new date field to store the date on which the record has been moved to that particular state.Create another field to record the date of creation of the record. Use datetime library for calculating the measure you want from 2 days.As an example if you want to get the number of days between these 2 days see the below added example. 

Eg:  

creation_date = datetime.strptime(str(self.creation_date), "%Y-%m-%d")
state_change_date = datetime.strptime(str(self.state_change_date), "%Y-%m-%d")
days_difference = state_change_date - creation_date.days

Regards 

อวตาร
ละทิ้ง
ผู้เขียน

Thank you very much!.

I didn't have to use strptime methods just modify the deltavalue and point it to be days. as eg:

(stage_change_date - creation_date).days , this would be stored in the integer field I have as "difference between days"

ผู้เขียน คำตอบที่ดีที่สุด

‎ ‎

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
4
ก.ย. 20
8811
3
ส.ค. 23
25707
1
ก.ค. 25
1668
4
เม.ย. 25
11982
1
ก.พ. 25
3389