Date conversion

paivers

Board Regular
Joined
Sep 4, 2009
Messages
64
I have a text field that contains a combination of dates and nulls (i.e. ISBLANK returns false, but ="" returns true). The problem is I want to convert to Datetime to do arithmatic on it, but when I try DateValue([MyDate]) I get a type mismatch even though that takes a text. I though it was the content perhaps so I tried
=if([MyDate]="",Date(1900,01,01),DateValue([MyDate]))

But still a type mismatch. The source of the field is an MDX query to a traditional cube, but that shouldn't make a difference. How can I convert this to a date?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi,

Can you post up the format that your text date is in?

What error are you getting? Is it #Value ?

Regards,
Chris
 
Upvote 0
Just to add to the above, If I have :-

21 Jan 2012 formatted as text then =DATEVALUE on this Text date returns the date serial number (Which you can use for calculations)

However, if I use:-

Jan 21 2012

Then I get a #Value error...........

Is this what you are seeing?
 
Upvote 0
Edit..............

Just noticed this is in the powerpivot section, so not sure if my comments above are still applicable (I picked up your question from the zero replies section!) Apologies if they are not relevant........
 
Upvote 0
Powerpivot will not allow multiple data types in the same formula (unlike Excel) and it sees "" as text.

try blank() instead of ""
 
Last edited:
Upvote 0
Sorry for the delayed response, I'll try to address all the suggestion. The specific error is:
>> Warning 1 Calculated column 'MyTable'[MyDate] : The following system error occurred: Type mismatch.

In its simplest form the expection I have is:CalculatedColumn=datevalue([MyDate])
where the CalculatedColumn is type Date

MyDate is of type "Text" and contains values including blanks and values such as "2013-01-14 14:45:00.000". Is is sourced from an MDX query from SSAS.

So all I want to do is get the date text to date format. My basic goal is to tell whether I have a date within the past year. Blank would be negative, but if I have a date I need to get to date format so I can calculate, but no luck doing that.
 
Upvote 0

Forum statistics

Threads
1,215,007
Messages
6,122,670
Members
449,091
Latest member
peppernaut

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