+ Reply to Thread
Results 1 to 7 of 7

Datevalue - Same value, one returns error?

  1. #1
    Forum Contributor
    Join Date
    08-12-2006
    Posts
    106

    Datevalue - Same value, one returns error?

    I have a value in a cell named period. It shows in formulabar 1.4.2012 (April 1st 2012). I try formula
    =DATEVALUE("1.4.2012")
    gives 41000 exactly like it should.
    =Period=DATEVALUE("1.4.2012")
    returns TRUE exactly like it should.

    However,
    =DATEVALUE(Period)
    returns #VALUE!

    I don't get it. Naturally I want that lower one to work.


    edit. Also
    =DATE(YEAR(Period);MONTH(Period);1) works fine, but
    =DATEVALUE(DATE(YEAR(Period);MONTH(Period);1))
    does not
    Last edited by Jaymond Flurrie; 05-07-2013 at 10:28 AM.

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Datevalue - Same value, one returns error?

    Datevalue converts a TEXT string to a Date.
    Your Named Range period contains a DATE not a text string.
    So Datevalue(Period) errors, because Datevalue is looking for a TEXT string.

    so instead of
    =DATEVALUE(Period)
    you would just write
    =Period

  3. #3
    Forum Contributor
    Join Date
    08-12-2006
    Posts
    106

    Re: Datevalue - Same value, one returns error?

    Quote Originally Posted by Jonmo1 View Post
    Datevalue converts a TEXT string to a Date.
    Your Named Range period contains a DATE not a text string.
    So Datevalue(Period) errors, because Datevalue is looking for a TEXT string.

    so instead of
    =DATEVALUE(Period)
    you would just write
    =Period
    Thanks for the answer!

    I need to match the given date to an array of dates named TestName, currently the array has one date, April 1st 2012. Datevalue of it is 41000 i.e. a match. Now when I input a formula like:
    =MATCH(DATE(YEAR(Period);MONTH(Period);1);TestName;0)
    or
    =MATCH(Period;TestName;0) (Which would be the ideal case)
    or
    =MATCH(DATEVALUE(Period);TestName;0)

    I get #VALUE!

    Maybe Datevalue is not the function I should use?

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Datevalue - Same value, one returns error?

    Quote Originally Posted by Jaymond Flurrie View Post
    Thanks for the answer!

    I need to match the given date to an array of dates named TestName, currently the array has one date, April 1st 2012. Datevalue of it is 41000 i.e. a match.
    If Datevalue returns 41000 for the date in the TestName range, then that means that it IS a text string.
    But again, Period is NOT a Text string.
    = No Match.

    I think you should attach a sample book.

  5. #5
    Forum Contributor
    Join Date
    08-12-2006
    Posts
    106

    Re: Datevalue - Same value, one returns error?

    I hope this one clears it up. Note that the TestName on row 2 has to be expandable (otherwise the match function is - obviously - needless).

    edit. Also, it is worth of noting that the A1 has to be displayed in that format (MM/YYYY) and that the TestName values are coming from SQL Server - although I'm free to modify the query anyway I want.
    Attached Files Attached Files

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Datevalue - Same value, one returns error?

    your testname data is text so you either have to convert the lookup value to text (using the text function, and matching formats) or convert the testname data to dates which will only work if you have more than one cell (or the MATCH function won't work). for instance you can redefine the testname data to use
    =DATEVALUE(Sheet1!$A$2:$A$3)
    then use your match function
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  7. #7
    Forum Contributor
    Join Date
    08-12-2006
    Posts
    106

    Re: Datevalue - Same value, one returns error?

    I got it to work, thanks for the help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1