Skip to Content
author's profile photo Former Member
Former Member

IsDateTime() function evaluates numbers 1,2,3 as Date

I'm using following code in format formula it's working but for numeric data i.e. 1,2,3 the function

IsDateTime(ToText(CurrentFieldValue))

returns true and in turn it shows numbers 1,2 as 31 Dec 1899

if IsDateTime(ToText(CurrentFieldValue)) then
    (
        ToText(CDate(CurrentFieldValue), "dd MMM yyyy")
    )
else
    ToText(CurrentFieldValue)

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Dec 07, 2011 at 10:54 PM

    Hi,

    I think I'm missing something. The CurrentFieldValue, is this an actual number type? What does the CurrentFieldValue actually look like?

    Crystal returns an error when I have a number formatted like "1,2,3". This is what I expected.

    Can you provide an actual example of what the CurrentFieldValue should be?

    Crystal normally returns December 31, 1899 if it encounters an empty date.

    Out of curiosity, if the CurrentFieldValue is a String remove the ToText function in the If.

    I created a formula like:

    StringVar myString := "1,2,3"; 
    
    If IsDate (myString) Then 
        ToText (cdate (1,2,3), "dd MMM yyyy") 
    Else myString;

    This returned 03 Feb 1 for me. Again, what I would expect.

    Thanks,

    Brian

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Brian Dong

      Brian,

      Thanks for your commitment.

      The data for report is not input from user, actually user selects database fields to show and it can be of type String (varchar), DateTime and Number. So, data type in report keeps changing. among these three types.

      Regards,

      Adil

  • author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2011 at 09:00 PM

    HI

    Totext always return thousand separator and also decimal places. You will have to change this formula as :

    if IsDateTime(ToText(CurrentFieldValue)) then

    (

    ToText(day(CDate(CurrentFieldValue), "00")& left(ToText(Monthname(month(CDate(CurrentFieldValue)))),3)& ToText(Year(CDate(CurrentFieldValue), "0000")

    )

    else

    ToText(CurrentFieldValue)

    Thanks,

    Naga

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.