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

  • Home
  • SEARCH
  • 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 8059907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:49:05+00:00 2026-06-05T09:49:05+00:00

I am looping through a range of consecutive dates. I need to find out

  • 0

I am looping through a range of consecutive dates. I need to find out which are weekends so they can be discarded. One method would be to determine the day of week via perl (what my script is written in) or query with each pass through the loop. There will never be more than 30 dates, usually 5 or less to check. Would it be more efficient to load up Date::Time and use perl or run a Query without needing modules? If perl is the best method I could use a little help extracting the day of week from the YYYY-MM-DD format. I’d be ok with number 1-7 or shortname mon-sun.

2012-05-01
2012-05-02
2012-05-03
2012-05-04
2012-05-05
2012-05-06

not sure if this is possible but perhaps a more suitable solution would be to write a query (since I know the start and end and they are consecutive) to count days between x and y where dayofweek NOT IN(6,7)

  • 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-05T09:49:07+00:00Added an answer on June 5, 2026 at 9:49 am
    use Date::Simple qw/date/;
    use Date::Range;
    
    my ( $start, $end ) = ( date('2012-05-02'), date('2012-05-16') );
    my $range = Date::Range->new( $start, $end );
    my @all_dates = $range->dates;
    
    foreach my $d (@all_dates) {
      my $date  = Date::Simple->new($d);
      print $date->day_of_week." ".$d."<br />";
      }
    
    #--OUTPUT--#
    
    3 2012-05-02
    4 2012-05-03
    5 2012-05-04
    6 2012-05-05
    0 2012-05-06
    1 2012-05-07
    2 2012-05-08
    3 2012-05-09
    4 2012-05-10
    5 2012-05-11
    6 2012-05-12
    0 2012-05-13
    1 2012-05-14
    2 2012-05-15
    3 2012-05-16
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While looping through a Dataset which code snippet should I use, should I go
I am looping through ArrayList<Bar> . Foo extends Bar . I'm trying to find
I have a function that will take a range of values, which need to
When looping through a DataRow and encountering types such as DataRow dr; dr[someString] dr[someInteger]
I am looping through a large text file and im looking for lines that
I'm looping through an associative array with a foreach. I'd like to be able
I'm looping through thousands of strings with various regexes to check for simple errors.
I'm looping through multiple checkboxes with the same class with function each() and inside
I am looping through an array of strings, such as (1/12/1992 apple truck 12/10/10
I'm looping through the page controls like so foreach (Control ctrl in control.Controls) {

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.