Cdate is a visual basic command as far as I know. Crystal reports (8.5) has a date(yyyy,mm,dd) function you can use in the formula. and a date(DateTime) function. you'll have to play with both of them to get it to work correctly, I'm not sure what date/time formats the 2nd one takes, and for the first one, you'll have to parse the text field appart.
CDate Function Example
This example uses the CDate function to convert a string to a Date. In general, hard-coding dates and times as strings (as shown in this example) is not recommended. Use date literals and time literals, such as #2/12/1969# and #4:45:23 PM#, instead.
Dim MyDate, MyShortDate, MyTime, MyShortTime
MyDate = "February 12, 1969" ' Define date.
MyShortDate = CDate(MyDate) ' Convert to Date data type.
MyTime = "4:35:47 PM" ' Define time.
MyShortTime = CDate(MyTime) ' Convert to Date data type.
In Crystal 8.5, you can type in a string literal (such as you gave in your example) as follows:
CDate ("2001-08-01"
and it will return 08/01/2001. Obviously, it would be better if you didn't have to hardcode the date or use date literals as Olichap suggested. Hope this answers your question.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.