Why the ‘date_query’ is not working in ‘pre_get_posts’ hook?

You’ve got trailing space in your $query->set().

Instead of

$query->set( 'date_query ', ...

it should be:

$query->set( 'date_query', ...

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)