Skip to main content
Inspiring
July 11, 2008
Question

date object validation

  • July 11, 2008
  • 3 replies
  • 602 views
Hi All,

I've been looking at date and decision functions but I can't seem to find one which will check if a certain value/variable is a date object or not. I can't use IsDate 'coz this will only check if a certain string can be converted to a date. What I mean is, example, I will know that a certain value is a date object if that value is returned by a Now() function or a CreateDate/CreateDateTime function. These functions will return date objects. But how do I check if a certain value is a date object or not?

Example: Now() returns a date object, so this is a date object. But if I manually input, say "2008-07-11", this is not a date object since I just input it as a string.

Thanks.
    This topic has been closed for replies.

    3 replies

    dongzkyAuthor
    Inspiring
    July 11, 2008
    i want to check an object if it is a date object just as i want to check a variable if it is of float data type or not. Something like it.

    the isdate doesn't give me what i wanted since even if i input this as a string "2008-07-11", it still gives me true, Isdate just tests if that string can be converted to a date.

    scenario:
    if i manualy type "2008-07-11", this is just a string and not a date object.

    if i say createdate(2008,7,11), this is a date object.

    I hope I make sense on this. Thanks.
    Inspiring
    July 11, 2008
    quote:

    Originally posted by: dongzky
    i want to check an object if it is a date object just as i want to check a variable if it is of float data type or not. Something like it.

    the isdate doesn't give me what i wanted since even if i input this as a string "2008-07-11", it still gives me true, Isdate just tests if that string can be converted to a date.

    scenario:
    if i manualy type "2008-07-11", this is just a string and not a date object.

    if i say createdate(2008,7,11), this is a date object.

    I hope I make sense on this. Thanks.

    If you are talking about user inputs, they will never be valid date objects. They will be strings. What else did you want to test?
    Inspiring
    July 11, 2008
    IsDate() is pretty good except that the last time I tried it, it would return true on the occasional non date such as "Apr 31".

    In my apps, I only get data from user inputs (forms), or dbs. If I select a date field from a db, I don't have to check anything. Starting with CF7, the combination of masks and validate attributes in cfinput make it easy to prevent users from submitting anything that is not a date. I combine this with a couple of custom tags I wrote several years ago that use isDate().

    What scenario do you have that makes isDate inadequate?
    Inspiring
    July 11, 2008
    Hi,

    Have you tried the "CheckPattern" udf?
    dongzkyAuthor
    Inspiring
    July 11, 2008
    quote:

    Originally posted by: Daverms
    Hi,

    Have you tried the "CheckPattern" udf?


    I tried the udf, but still failed to give me the result I want. By the way, is the "isDate" checking there suppose to determine if it is a date object? It seems like it just looks for patterns. I'm not sure though. What I am trying to achieve is to validate a value/variable if it is a date object. Just like when you want to validate a variable if it is an integer data type, or maybe if it is a srting data type, or maybe it is a boolean data type, etc. Maybe there is a core java for this? But how? What function? Thanks.