Converting YYYYMMDD into proper Date

dotsent

Board Regular
Joined
Feb 28, 2016
Messages
89
Office Version
  1. 365
Platform
  1. Windows
Hi!

I have an Excel 2016 worksheet with a data connection to db where I query contents to Excel. It is a simple table with invoice numbers and due dates. Those are exclusively unpaid overdue invoices. SQL query identifies if the invoice is open (unpaid). The date is kept as a decimal in the database and has a format YYYYMMDD

A1 cell in my workbook is equipped with a formula =TEXT(TODAY(); "yyyymmdd") - it displays the current date in the same format. The query uses value in this cell to identify if the open invoice is overdue (i.e. Due date is smaller than A1 value). This is done via table parameters setup. This works like a charm - I only get invoices in my table that are open + are past the due date.

I'm struggling to calculate the correct number of days overdue though. I have created an extra column to the table with formula "=A$1 - Due Date", however the format does not support correct calculations. E.g. on November 1st for an invoice with due date on October 1st the calculating process would work =20181101 - 20181001 = 100 days, which obviously isn't correct.

SQL query would not allow me to use CAST function to turn decimal value to DATE and I can't really mess around with the date format in cell A1 to keep it functional for query purposes.

I guess I'm looking for options how to turn value YYYYMMDD into properly formatted date in a helper column, which would be usable in formulas? How could I do that or are there alternative approaches?

Thanks!
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Re: Coverting YYYYMMDD into proper Date

How about
=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))
 
Upvote 0
Re: Coverting YYYYMMDD into proper Date

One way:

=--TEXT(A1,"0000\/00\/00")
 
Upvote 0
Re: Coverting YYYYMMDD into proper Date

Thanks guys! I used the =--TEXT(A1,"0000-00-00") option and it worked nicely! Option by Fluff worked too, however I found TEXT function to be simpler. I had to remove the "--" from ahead of TEXT though. What was the function of that?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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