# Calculating number of working days between two dates

## Here is a simple, small formula for finding working days between two days (i.e. days excluding holidays and weekends.)

A simple small formula for finding working days between two days (i.e. days excluding holidays and weekends.)

Steps followed:

1) Holidays are populated from a view named holidays;

2) date range arrived by exploding;

3) Holidays in the date range replaced with null value , resulting in all days in the range except the holidays;

4) Next step is to remove all weekends ;using @weekdays and removing 1's and 7's(sun=1 and sat=7)
*FROM and TO are two date fields*

```FIELD holidays:=@Dbcolumn("":"NoCache";"";"Holidays";1); FIELD dateRange:=@Explode(@TextToTime(@Text(FROM)+"-"+@Text(TO))); FIELD wkgDaysWithWE:=@Weekday(@TextToTime(@Trim(@Replace(dateRange;holidays;NULL)))); @Elements(@Trim(@Replace(@Text(wkgDaysWithWE);"1":"7";NULL))); OR use this one liner ;-) @Elements(@Trim(@Replace(@Text(@Weekday(@TextToTime(@Trim(@Replace(date
Range;holidays;NULL)))));"1":"7";NULL)));
```

#### Join the conversation

Send me notifications when other members comment.
FIELD holidays:=@Dbcolumn("":"NoCache";"";"Holidays";1);
FIELD dateRange:=@Explode(@TextToTime(@Text(Start)+"-"+@Text(End)));
FIELD wkgDaysWithWE:=
@Weekday(@TextToTime(@Trim(@Replace(dateRange;"";NULL))));
@Elements(@Trim(@Replace(@Text(wkgDaysWithWE);"1":"7";NULL)));

finalDateList:="";
@Transform( dateRange ; "variableName" ;

finalDateList := finalDateList + @If( @Weekday(@TextToTime(@Trim(variableName)))=1:7 ; "" ;

@If( finalDateList = "" ; "" ; ",") + variableName )

);
finalDateList;
Cancel
The Formula above provides the actual list of dates minus weekend and holiday dates.
Cancel

## SearchWindowsServer

• ### February Patch Tuesday resolves IE zero-day

Microsoft released security updates for 99 unique vulnerabilities, including an Internet Explorer flaw the company had notified ...

• ### What's new with PowerShell error handling?

PowerShell 7 introduces a new cmdlet to assist administrators who wanted a better way to find out what broke in the scripts they ...

• ### Why move to PowerShell 7 from Windows PowerShell?

The next major release of this venerable automation tool features performance improvements and a bevy of new features that could ...

## Search400

• ### iSeries tutorials

Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

• ### V6R1 upgrade planning checklist

When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

• ### Connecting multiple iSeries systems through DDM

Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

## SearchDataCenter

• ### Initiative aims to improve data center incident reporting

The Data Center Incident Reporting Network hopes to pull back the smoke screen on software and hardware issues to improve ...

• ### A guide to GPU implementation and activation

Data center GPU usage goes beyond hardware. Admins must work with vendors and developers to have the right software architecture ...

• ### Key components for negotiating an HPC colocation contract

When it comes to HPC colocation, there are specialized areas to cover in a service-level agreement. Review provider protocols for...

## SearchContentManagement

• ### Akeneo rolls out newest version of PIM software

Akeneo PIM version 4.0 features digital asset manager, API-integrated connection modules and AI attribute mapping to better ...

• ### Get to know 4 workflow automation tools

Workflow automation can benefit businesses by making manual processes digital, giving employees more time to work on other tasks....

• ### Decide if paywall content is right for your business

Organizations that sell content might benefit from a paywall. Here are some questions to ask when deciding if a paywall strategy ...

Close