?
Solved

Min Date of a column that contains NULLS

Posted on 2014-07-28
6
Medium Priority
?
261 Views
Last Modified: 2014-08-02
Hello

I would like to return the Min Date of a column that contains NULLS, which means the Min Date is always a NULL. I cannot remove these records from the record set.
I thought about a formula field that said something "if date is NULL then 01/01/2999 (a date miles in the future)" then running a MIN down this formula field but that seemed like an odd way of tackling the problem.

What is the correct solution to this problem?

Thanks
0
Comment
Question by:BananaFury
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 35

Expert Comment

by:ste5an
ID: 40224354
Change the data source. Use COALESCE() to set an appropriate minimum value.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 501 total points
ID: 40224386
Your idea is probably the easiest way in Crystal to handle the issue.

Something like

If IsNull({YourDateField}) then
      Date(2099,1,1)
Else
     {YourDatefield}

Open in new window


You can use any date for the default.  If you know the dates are generally in the past then you could use CurrentDate as the date.  In that way the formula could potentially also be used to find the maximum.

Another other way to do this would be to use a VIEW/Stored Procedure in the database or a Crystal COMMAND as the datasource.  You would then have the minimum date in each record.  That would use the suggestion above.

You could use a subreport to get the minimum date using a selection filter in the subreport that is the same as the main report with an added filter to eliminate the NULL dates.

Depending on the database you may be able to use a SQL Expression to get the minimum date.

mlmcc


mlmcc
0
 
LVL 13

Assisted Solution

by:PCIIain
PCIIain earned 249 total points
ID: 40226129
Another way would be to use a running total, reset whenever necessary and evaluated on a formula, where the formula is :-
not isnull(<fieldname>)
0
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 

Author Comment

by:BananaFury
ID: 40228543
Thanks mlmcc, using a CurrentDate as a default is an obviously better idea than my massive future date, but not one that I had thought of actually. The report is bolted onto a stored procedure, running from some tables in a SQL DB so I could tweak the source, but I don't really want to do that. What is a Crystal COMMAND though? Never heard of that.

Thought about the sub reports idea, and passing out the value via a variable, but I have half a dozen or so formulas like this to create, so didn't really fancy that many subs all with there own link to a table, seemed a little data hungry.

The running totals is something I hadn't thought about either. That would be a slightly painful solution for me as I believe I would need to move everything to footers to use RT's.

thanks all
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 501 total points
ID: 40228969
A Crystal command is a data source for the report.  You select it then build the SQL in the command window.  

mlmcc
0
 

Author Closing Comment

by:BananaFury
ID: 40235774
Thanks, I went with the CurrentDate solution.

The Crystal Commands are interesting, never seen or used these before. I can imagine using these at some point

thanks all
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question