跳至內容
選單
此問題已被標幟
2 回覆
2835 瀏覽次數

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"

作者 最佳答案

‎ ‎

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
4
9月 20
8805
3
8月 23
25700
1
7月 25
1664
4
4月 25
11974
1
2月 25
3380