1

Topic: Include Darwin Core format date in report wizard

Hello,

Please could the Sample Date be available in Darwin Core format (as suitable for the NBN Atlas) from the Report Wizard please.

I assume this is possible as it is part of the NBN Atlas export Add-in.

Phil

CPERC

2

Re: Include Darwin Core format date in report wizard

Hi

Attached is  the SQL designed to add Darwin_Core date to the Report Wizard. It needs to be run in Management Studio as a New Query. Best bet is to open Management Studio and copy and paste the contents of the files in a New Query. It should add a new Report Field under SAMPLE  for the R6 sample date  in Darwin Core format. Unknown and dates and a vague date type not supported in Darwin Core will be null values. This includes the Months and Seasons  without a year, and and years with no end date. (M', 'S' and 'Y-' in R6 Vague date Types).

I have run it on a live database and it looks OK but please carry out your own testing and let me know of any problems.

Mike

Post's attachments

Darwin_Core_Date_Script.sql 5.02 kb, 5 downloads since 2024-09-26 

You don't have the permssions to download the attachments of this post.
Mike Weideli

3

Re: Include Darwin Core format date in report wizard

Mike,

Thanks. I have now got around to trying this but on running the query it had the following errors -

Msg 195, Level 15, State 10, Procedure LCReturnDCDate, Line 24 [Batch Start Line 7]
'trim' is not a recognized built-in function name.
Msg 195, Level 15, State 10, Procedure LCReturnDCDate, Line 25 [Batch Start Line 7]
'trim' is not a recognized built-in function name.
Msg 195, Level 15, State 10, Procedure LCReturnDCDate, Line 26 [Batch Start Line 7]
'trim' is not a recognized built-in function name.
Msg 195, Level 15, State 10, Procedure LCReturnDCDate, Line 29 [Batch Start Line 7]
'trim' is not a recognized built-in function name.
Msg 195, Level 15, State 10, Procedure LCReturnDCDate, Line 30 [Batch Start Line 7]
'trim' is not a recognized built-in function name.
Msg 195, Level 15, State 10, Procedure LCReturnDCDate, Line 31 [Batch Start Line 7]
'trim' is not a recognized built-in function name.
Msg 15151, Level 16, State 1, Line 62
Cannot find the object 'LCReturnDCDate', because it does not exist or you do not have permission.

(0 rows affected)

(0 rows affected)

(1 row affected)

(1 row affected)

Completion time: 2025-02-10T11:52:59.9918997+00:00


The option to choose the Sample Darwin Core Date then does come up in the Report Wizard in Recorder but when selected there is an error which says 'Cannot find either column "dbo" or the user-defined function or aggregate "dbo.LCReturnDCDate", or the name is ambiguous.'

Phil

4

Re: Include Darwin Core format date in report wizard

Hi

I expect this is down to the version of SQL Server you are using. Trim didn't come in until SQL Server 2017.  The SQL needs changing TRIM  to  LTRIM.  Is this something you could do ?. If not I will look at it asap.

Mike

Mike Weideli

5

Re: Include Darwin Core format date in report wizard

Hi Mike,

Yes I think it is SQL Server 2016. I am using the most up to date version of Management Studio though. I could try and amend your code but it is probably safer if you do. Also as it has now already put a 'Sample Darwin Core Date' in the report wizard (which does not work) I am concerned that putting another one in might cause a conflict, so might need another change in the code so it doesn't? (Perhaps just change the name of it?).

Thanks,

Phil

6

Re: Include Darwin Core format date in report wizard

Hi

The attached should allow it to work on any version of sql server. When you ran the original script it will have added DC to the report wizard. However, the script allows for this so running it again should be ok.

Post's attachments

Darwin_Core_Date_Script.sql 5.03 kb, 5 downloads since 2025-02-12 

You don't have the permssions to download the attachments of this post.
Mike Weideli

7

Re: Include Darwin Core format date in report wizard

Hi Mike,

I have tried this now and there is an error in one line where 'Lrim' should be 'Ltrim'. See below -

Msg 195, Level 15, State 10, Procedure LCReturnDCDate, Line 30 [Batch Start Line 7]
'Lrim' is not a recognized built-in function name.

I corrected this myself and ran again and it works now.

However, I did an export with a variety of different date types after this and there was one record with a date range -

'21/07/2013 - 24/07/2013'

This came out as '2013-07--21/24'

But should be '2013-07-21/24' I think (with one -) looking at the NBN Atlas upload template guide.

Could you correct the above in the script and post again please?

Thanks,

Phil

8

Re: Include Darwin Core format date in report wizard

Hope this will fix the issue.

Post's attachments

Darwin_Core_Date_Script(4).sql 5.01 kb, 1 downloads since 2025-02-17 

You don't have the permssions to download the attachments of this post.
Mike Weideli

9

Re: Include Darwin Core format date in report wizard

Thanks Mike, that has worked. This will help quite a few people I think.