Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

How to Create Date from Excel Date Formatted as Number


Hey Mike, 

Yes, because previously we didn't need this date as we had a different system of identifying what the date value should be for our trending that was more of a manual/vlookup process. I'm automating wherever possible at this point, so doing it that way is not an option. Whoever created the initial macro in excel, didn't change that column to a date format. Now I have ~500 fairly large files that don't have this particular date field formatted as a date. From here on out, that Excel Macro is being converted to Alteryx, and the date format problem will be fixed. However, for creating a historical database, I can't really go back in time and change the macro, and I was trying to avoid spending a few hrs opening, adjusting, and saving each file.


I'll give it a go with the 1899 date instead of the 1900 date, and since all my dates would be past 3/1/1900, I would then still need to make a 1 dat adjustment, correct? 


My confusion arose when I took 1/1/1900 + the number of days from the 12/6 file  -3 and got 12/6. Then I did the same equation with the 12/7 file and got 12/6 again instead of getting 12/7. 


I need to put this project away for now as I've found a way to at least provide the same data I was before, though not more detailed like I was hoping. I will dive back into it next year and try again once I have some more time on my hands. 




Ok, that makes sense.


You should be able to do the conversion, like we are doing in the Alteryx code.

If you google convert double to date you'll see that there are a lot of ways to do it.


A value of 0 is Dec 30, 1899 at midnight - due to the Lotus 1-2-3 leap year bug which Excel inherited.

All dates between Jan 1, 1900 and March 1, 1900 are off by one because of this.

So I believe your calculation needs to count the number of days since Dec 30, 1899, not Jan 1, 1900.


Also, beware of rounding errors that can occur when doing math with doubles.


we offset the value by a half second in order to avoid rounding errors:

        // Offsetting by a 1/2 second to avoid rounding errors
        excelDateValue += 0.5 / (24 * 60 * 60);

We then use the new value to do our calculations with. I can't remember if the rounding we saw was

in the date or time components, or both. Your comment that some dates are off by one made me

think that the rounding might be the problem.


I hope this is helpful




I have run into the same issue, my Excel dates are stored as date values and i need to convert them into a real date.

The source file is 1.6M lines so too big for Excel to read and convert, would you be able to share your formula to reconvert them? 






Here's a quick workflow that converts a double (Excel date) to a Datetime in Alteryx


See attached workflow.

It uses this function in a formula tool:



where Datebase = a datetime value set to "1899-12-30 00:00:00"

and Field1 is my double value = 42397


The answer if you run the workflow is today's date: "2016-01-28 00:00:00"


Hope that helps


I'll try it right away! 






Keep in mind that the double value may have a fraction (significant digits to the right of the decimal point).

The decimal part relates to the time.

For example 42397.5 would be Noon instead of midnight (which is 42397.0)

and 42397.25 is 6am


so, if you have a time component, you'll have to deal with that part separately.

The formula I gave you will take the whole number part and convert that to a date, but won't get you the time.




My number doesn't have a decimal fortunately ;-) 

However I know bump into a new issue, it takes the first input of the formula but doesn't recognise the value in the array to be added. 


Specifically the error message says: 

Error: Formula (120): The formula "Date" resulted in a string but the field is numeric. Use ToNumber(...) if this is correct. (Expression #1)


I tried using the ToNumber function but i get the same message again



Any idea why that may be?






Make sure the field type in the formula is Date or Datetime not Numeric (like Int32)


Thanks Mike. 


I tried that already before posting. Time component is very important for me and the example in the other link gives only date.