# How to use Excel to calculate seniority

Source: Internet
Author: User
Tags current time

Today, a financial, MM asked me Excel calculation seniority problem, I think, I really do not ah. The test, write case, report progress, statistical bugs are generally used in Excel, and really did not have to calculate the date of seniority birthdays and so on.

Her request was:

Incredibly not, think half a day to think of 2 schemes: 1, write a script to her in Perl; 2, the information into the database, with the SELECT statement query and then export the results;

Later, think carefully, this does not meet her requirements, people want to use Excel to solve. So I started looking for Excel function, about date processing.

In general programming languages and databases, there are functions to get the current date and string processing, so I follow this idea to find. (She did not ask for a 3.5-year seniority, only for a full month)

The function that Excel obtains the current date is:

Today () Gets the system date display:

1/2/2013

Now () Get system date and current time

1/2/2013 12:13

Because no system time is required, choose today ()

Time processing function: Datedif (start_date,end_date,unit)

The start_date and end_date parameters of the DATEDIF function are the starting and ending dates, and the unit is what the user expects the DATEDIF function to return. Unit units have six kinds,

The distinction is: "Y": All Year "M": Full Month "D": All Day "YM": The number of months in less than a year "YD": Days in less than a year "MD": Days less than one months to notice is

Note: 1. The DATEDIF function must include double quotes when entering the unit parameter. 2.start_date

Example:

Datedif ("2001-09-01", "2013-01-01", "Y") 11

Datedif ("2001-09-01", "2013-01-01", "YM") 4

Datedif ("2001-09-01", "2013-01-01", "MD") 0

Datedif ("2001-09-01", "2013-01-01", "YD") 122

The rest is easy and needs to be

Excel Connectors &

Get Datedif (a2,b2, "Y") & "-" &datedif (A2,B2, "YM") & "-" &datedif (A2,B2, "MD") work all the year round

Computer Tutorials

Additional thinking:

What is the date of birth of the ID number?

First, determine if the ID number is 18 digits, Len (str).

=if (len (str) =18,true,false)

Intercept the year of birth mid (a2,7,4) from the seventh digit of Cell A2, intercept 4 (7, 8, 9, 10)

Related Keywords:
Related Article

## E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

## Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

## Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth \$300-1200 USD

Learn more >

### Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.