Results 1 to 4 of 4

Thread: Date comparison

  1. #1
    Join Date
    Sep 2003
    Posts
    2

    Unanswered: Date comparison

    Hi all!

    I am looking for a way in perl that will check the system time to see if a specific date ($enddate) has passed and return an option for each. The overlap into the next year may be as long as 6 months. Any help would be greatly appreciated!

    Thanks in advance!
    Jim

  2. #2
    Join Date
    Sep 2003
    Posts
    2

    Nevermind

    Figured it out......

    I added this to format the date:

    # Adjust system date format for comparison
    # Adjusts the (0-11) format of month to (1-12)
    $mon = $mon + 1;

    # Adds a 0 before any months that are less than 10
    if ($mon < "10"){
    $mon = 0 . $mon;

    # Converts to yyyymmdd format
    $date1 = $year . $mon . $mday;
    }
    else{
    $date1 = $year . $mon . $mday;
    }

    And this to compare an ending date from my user database

    # Converts secondary date to yyyymmdd format
    $date2 = $endyear . $endmonth . $endday;

    # compare current system date to end date, else expired message
    if ($date1 <= $date2){
    }
    else {
    }

  3. #3
    Join Date
    Aug 2003
    Posts
    13
    i don't have an answer to your question, but i can shorten your code.
    change the first if statement to
    if ($mon < "10"){
    $mon = 0 . $mon;
    }
    date1 = $year . $mon . $mday;

    this removes the else statement completely

  4. #4
    Join Date
    Sep 2003
    Posts
    2

    Re: Date comparison

    Originally posted by jm285
    Hi all!

    I am looking for a way in perl that will check the system time to see if a specific date ($enddate) has passed and return an option for each. The overlap into the next year may be as long as 6 months. Any help would be greatly appreciated!

    Thanks in advance!
    Jim
    Hi ,

    Use DateManip module, if u have any doubts let me know.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •