Filter query based on date in custom field

You can use this format of meta_query, although you’d have to change the format of all of your existing expiry-date entries.

'meta_query' => array(
    'key' => 'expiry-date',
    'value' => array($today, $UserInputExpiry),
    'compare' => 'BETWEEN',
    'type' => 'DATE'
)

The second date in the array is the later date and both $today and $UserInputExpiry should be in the format YYYY-MM-DD.

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