Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8394397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:03:02+00:00 2026-06-09T20:03:02+00:00

I am trying to find the week that a date falls in, in a

  • 0

I am trying to find the week that a date falls in, in a certain year. I have a bunch of files that need to be sorted into folders like “week1-2012” and “week34-2011”. I tried searching but a lot of the results aren’t really helping because I am currently using perl v5.6.1, super old and I can’t download any modules. I also found this link ( How do I calculate the week number given a date?) of interest but was wondering how I would go about getting the day of year and week easily. Was thinking of getting the month, and adding the appropriate amount of days to find out the day in the year. Any help would be appreciated. An example of the year format I am looking for is

//year 2012
S  M  T  W  R  F  S
            1  2  3    <-- week #1 
4  5  6  7  8  9 10    <-- week #2 //came from the link

//dec year 2011
S   M  T  W  T  F  S
27 28 29 31            <-- week #52 or 53, not to sure the actual week
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:03:07+00:00Added an answer on June 9, 2026 at 8:03 pm

    You can use core modules: POSIX and Time::Local

    1.parse your date to (sec, min, hour, mday, month, year)

    2.convert your date to seconds (epoch)

    3.use function strftime to get week from current date

    use strict;
    use Time::Local;
    use POSIX qw(strftime);
    
    my $date = '08/15/2012';
    my ($month, $day, $year) = split '/', $date;
    
    my $epoch = timelocal( 0, 0, 0, $day, $month - 1, $year - 1900 );
    my $week  = strftime( "%U", localtime( $epoch ) );
    
    printf "Date: %s № Week: %s\n", $date, $week;
    

    OUTPUT

    Date: 08/15/2012 № Week: 33
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find the timestamp of a certain day of the week
I'm trying to find all the dates that would form a whole week based
Trying to find an example that has css rollover using sprites & sliding door
While trying to find an answer to Android Jasper Reporting I found out that
Hi all I have an appointments table that has among other fields a DATE
I've been searching for the last week trying to find an answer to this
I am trying to efficiently find all the JIRA issues that were closed in
I have 2 date pickers that contain check boxes within the button pane. I
I have a table called 'games' that has a column in it called 'week'.
I'm trying to dynamically create 5 divs that represent 5 days of the week.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.