سؤال

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

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

try this way

Year(Cdatetime(<<your date time value here>>));

Try this

Year (DateValue ({Orders.Order Date}))

Here for example date field is Order date from Orders table.

Thank you. My reporting scenario had - {Orders.POST_DATE} in minimum(YearToDate) to maximum(LastFullMonth).

That was working fine until it was run in a new year. Then Crystal read the dates as the last day of last month and the first day of the new year.

After seeing the solution here. I modified my code this way, which works:

{Orders.POST_DATE} in DateSerial(Year (minimum(LastFullMonth)), 1,1) to maximum(LastFullMonth) which now forces the 1/1/yyyy to be the same year as the year in LastFullMonth.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top