1

Re: sample_vague_end

I'm pulling out the (latest) year a sample was observed using:

YEAR(Sample.Vague_Date_End)

Works for most dates, apart from those that have been recorded as a year - the year returned by the report is recorded year + 1?

Charlie Barnes
Information Officer
Greater Lincolnshire Nature Partnership

2

Re: sample_vague_end

I suspect this is because Vague_date_end is an integer, but the Year function is specified as working on datetime and some internal conversion isn't doing what you would expect.  The user defined function  [dbo].[LCReturnDate] can return a year. This takes the vague_date_end (or any date in integer format), the vague_date_type and the date part to be returned. The vague_date_Type is there just to cover the situation of  vague_date_type 'U' (unknown).

For example [dbo].[LCReturnDate] (Sample.vague_date_end, sample.vague_date_type,'Y') will return the correct year  unless  the vague date type is U (unknown) when it will return null. The function can also return other date parts.


Mike






















Mike

Mike Weideli

3

Re: sample_vague_end

MikeWeideli wrote:

I suspect this is because Vague_date_end is an integer

Ah yes that would probably explain it :rolleyes: Cheers Mike,

Charlie Barnes
Information Officer
Greater Lincolnshire Nature Partnership