+ Reply to Thread
Results 1 to 7 of 7

VBA macros isDate() function returning true for non-date value

  1. #1
    Registered User
    Join Date
    10-17-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    25

    Exclamation VBA macros isDate() function returning true for non-date value

    Hi Everybody,
    I have a code which needs to check the element of array is date or non date ,if the value is true i need to format the value with oracle to_date function which will be then inserted into DB .But when i use the isDate function it returns true for non-date value (9999-0002). . From the array , I will get a element like 12/31/2015 .For example , if isDate(12/31/2015) is true then the condition would be to_date('12/31/2015','YYYY-MM-DD ') " but as the isDate() function is returning true for 9999-0002 , it is appending the to_date for all the non-date values.Please suggest me a vba function which will check for actual date value
    My actual code look like below
    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA macros isDate() function returning true for non-date value

    9999-0002 is seen by Excel VBA as a valid date, it's the 1st February 9999.

    Try adding code to check the year after you've checked for a date.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    10-17-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: VBA macros isDate() function returning true for non-date value

    Hi Noorie,
    Thanks for your reply,
    I have checked using the Year function also and it returns 9999 which may not considered as valid value for date formatting. Please suggest

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA macros isDate() function returning true for non-date value

    Did you add a check to see if the year was in a suitable range?

    Perhaps something like this which checks that the year is between 2000 and 2030 inclusive.
    Please Login or Register  to view this content.
    By the way, does 9000-2 or similar values represent anything? For example an error code.

  5. #5
    Registered User
    Join Date
    10-17-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: VBA macros isDate() function returning true for non-date value

    Thanks you very much norie..Your solution worked..
    By the way to answer your question... 9999-002 is just a data feed representing a item-code and doesnt represent any error code

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA macros isDate() function returning true for non-date value

    Why is it in a field/column that should have dates?

  7. #7
    Registered User
    Join Date
    10-17-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: VBA macros isDate() function returning true for non-date value

    Actually array has series of values which means that it contains the values of different cell values which includes Item_code column and also Valid_date columns.
    Required is to add the to_date format for valid_date column alone.

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] IsDate function reading a non-date as true
    By Ricker090 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-09-2013, 11:18 AM
  2. Logical test in IF function returning TRUE when it should be FALSE
    By lvjeff in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-28-2012, 05:13 PM
  3. IsDate function looking for American Date
    By duckboy1981 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-20-2009, 11:48 AM
  4. [SOLVED] vba: isDate function
    By phil in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2006, 12:35 AM
  5. VBA function , IsDate() not available
    By Office Engineer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-27-2005, 03:05 AM

Tags for this Thread

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