it can be done by rules, here is a rule that calculate in DAYS the difference between two dates. my rules does the following, make necesary changes to fit your needs:
First convert both dates to an integer value, then substract them (date1-date2= diff-value in seconds), for days value divide diff-value by 86400 (24*60*60), this new variable convert it to an integer, this last value is the diference in days between those 2 dates. react on after saving(updating) your node, store this value by rules in a node hidden field, last add this field to your view.
rule's code:
{ "rules_parcialidad_calculate_dias_de_retraso" : {
"LABEL" : "parcialidad calculate dias de retraso",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "calculate retraso pago" ],
"REQUIRES" : [ "rules" ],
"ON" : { "node_update--parcialidad" : { "bundle" : "parcialidad" } },
"DO" : [
{ "data_convert" : {
"USING" : {
"type" : "integer",
"value" : [ "node-unchanged:field-fecha-de-parcialidad" ]
},
"PROVIDE" : { "conversion_result" : { "fecha_parcialidad_converted" : "fecha_parcialidad_converted" } }
}
},
{ "data_convert" : {
"USING" : { "type" : "integer", "value" : [ "node:field-fecha-de-pago" ] },
"PROVIDE" : { "conversion_result" : { "fecha_pago_converted" : "fecha_pago_converted" } }
}
},
{ "data_calc" : {
"USING" : {
"input_1" : [ "fecha-pago-converted" ],
"op" : "-",
"input_2" : [ "fecha-parcialidad-converted" ]
},
"PROVIDE" : { "result" : { "diferencia_en_segundos" : "direfencia_en_segundos" } }
}
},
{ "data_calc" : {
"USING" : {
"input_1" : [ "diferencia-en-segundos" ],
"op" : "\/",
"input_2" : "86400"
},
"PROVIDE" : { "result" : { "diferencia_en_dias" : "diferencia_en_dias" } }
}
},
{ "data_convert" : {
"USING" : { "type" : "integer", "value" : [ "diferencia-en-dias" ] },
"PROVIDE" : { "conversion_result" : { "retraso_dias_round" : "retraso_dias_round" } }
}
},
{ "data_set" : {
"data" : [ "node:field-parcialidades-dias-retraso" ],
"value" : [ "retraso-dias-round" ]
}
}
]
}
}