Hi , i am trying to set the post for 24 hours and with it will be changed

I’m not sure what you are trying to accomplish because you lack to point out your goal. But with some guessing I think you are trying to display a post for 24h and then randomly select a new one.

If thats the case, you are using the transient wrong.

/** 
 * First, try to check our transient for a daily post id
 */

if ( false === ( $my_post_id = get_transient( 'my_daily_post_id' ) ) ) {

    /**
     * No daily post ID, so create one
     */

    $args = array( 
        'posts_per_page'      => 1, 
        'orderby'             => 'rand', 
        'post_type'           => 'post', 
        'ignore_sticky_posts' => true,
    );

    $random_posts = get_posts( $args );
    $my_post_id = false;

    if( $random_posts ) {
        foreach( $random_posts AS $random_post ) {
            /**
             * The first on in our randomized array
             */

            $my_post_id = $random_post->ID;
            break;
        }
    }

    /**
     * Set a transient for 24h with the post ID
     */

    set_transient( 'my_daily_post_id', $my_post_id, 24 * HOUR_IN_SECONDS );

} 

/** 
 * Use our 24h post ID to find the post
 */

$args = array( 
    'p' => $my_post_id,
    'post_type'           => 'post', 
    'ignore_sticky_posts' => true,
);

$q = new WP_Query( $args );

if( $q->have_posts() ) {

    while( $q->have_posts() ) {

        $q->the_post();

        if ( has_post_thumbnail() ) {
            echo '<a href="'. get_permalink($q->ID). '">';  the_post_thumbnail();  echo ' </a>';
        }

        the_title();
        the_excerpt();

    }

} else {
    _e( 'Sorry no posts found!' );
}