date() what is used for?

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I am reading the article below. I know how to use Date() but I really can not see any use or befit of this function. The author gave some examples but again I do not see any use of these examples. Can you please give me examples where I really need to use date() function. Thank you so much.


<code style="font-family: "Courier new"; white-space: pre-wrap; color: rgb(69, 69, 69); font-weight: 600;">=DATE(2015, 5, 20)</code> - returns a serial number corresponding to 20-May-2015.
<code style="font-family: "Courier new"; white-space: pre-wrap; color: rgb(69, 69, 69); font-weight: 600;">=DATE(YEAR(TODAY()), MONTH(TODAY()), 1)</code> - returns the first day of the current year and month.
<code style="font-family: "Courier new"; white-space: pre-wrap; color: rgb(69, 69, 69); font-weight: 600;">=DATE(2015, 5, 20)-5</code> - subtracts 5 days from May 20, 2015.

https://www.ablebits.com/office-addins-blog/2015/06/10/excel-date-functions/
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I use it all the time. One of the main uses i see is there is no abiguity to its use. In the UK if i see 1/2/18 its the 1st of February 2018. In the US its the 2nd Jan 2018. With DATE there is no problem. Its also useful in lots and lots of different date formulae where you want to place an actual date in the formula and not use a cell reference that refers to a date.
 
Upvote 0
You have a date "2018-3-21" in A1, what's the date after 457 days?

=date(year(a1),month(a1),day(a1)+457)

after 34 month?

=date(year(a1),month(a1)+34,day(a1))

after 45 years?

=date(year(a1)+45,month(a1),day(a1))

after 4 years 5 month and 7 days?

=date(year(a1)+4,month(a1)+5,day(a1)+7)
 
Last edited:
Upvote 0
It simply returns a date in the short date format of your system and the examples are to show you different methods that might be used to do that.
 
Upvote 0
Another example, how to identify whether a year is a leap year? you can use following formula(year number stored in A1):

=IF(month(A1,2,29)=2,"Leap year","Not a leap year")
 
Upvote 0
The Date Function is also useful when constructing a date when the DAY, MONTH, and YEAR are in different cells


Excel 2010
ABCD
1DAYMONTHYEARDate
217120181/17/2018
Sheet1
Cell Formulas
RangeFormula
D2=DATE(C2,B2,A2)
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,198
Members
452,617
Latest member
Narendra Babu D

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top