Make a SQL query with wpdb in WordPress

The main problem is how you’re specifying the custom table name (e.g., $wpdb->cf7dbplugin_submits).

$wpdb only knows about the “built-in” tables when accessing a table name via $wpdb->xxx. To specify access a custom table name, use {$wpdb->prefix}custom_table_name.

The other thing I notice is that, for security purposes, you should never use interpolated variables
in an SQL statement passed to any of the $wpdb query methods. Instead, you should use $wpdb->prepare().

Putting these 2 things together results in:

$sql = $wpdb->prepare (
    "SELECT min(TIMESTAMPDIFF($day,`fecha_inscripcion`, $now))
    FROM  {$wpdb->prefix}cf7dbplugin_submits
    WHERE field_name=%s and field_value=%s",
    $fieldname,
    $fieldvalue
    ) ;
$post_count = $wpdb->get_var ($sql) ;