Search code examples
datetimecrystal-reportsformula

Extracting Only Year Value in Crystal Report DateTime Field


I am working with Crystal Report, right now I am in a situtation where I have to extract only Year value from a datetiem field, for example, if the value is : 01/03/2014 10:20:01AM

I only need to extract 2014

I did what is that , I changed the DataFormat of the field is dd/mm/yyyyy

Now i hav eapplied formula on it.

Formula = Right(CStr ({report;1.FirstYearDate}),4)

It shows 01AM

Kindly help me out


Solution

  • Here I have done with this way, my string was "01/02/2012 10:45:22Am"

    after using this formula:

    Formula = ToText({report_;1.FirstYearDate}, "yyyy")
    

    I have got this value :2012