Progress 8, CURRENT_DATE select - date

I´d like to execute a statement on my Progress DB (Major Version 8) which would look like this in SQL Server:
Select GETDATE()
or
Select Current_Date from DUAL
with Oralce
With Progress8, the date regisiter is, CURRENT_DATE.
My question is now: does a table like dual exist for Progress8 ? Or is this statement, that returns just a Date not possible ?
(I could create a Table like the DUAL Table, but i don´t have permission to it)

Progress is not SQL. Progress version 8 is also ancient, obsolete and unsupported. It was released in the 90s. The current version of Progress is OpenEdge 11 (the "OpenEdge" branding was introduced with version 9).
FWIW Progress 8 does have some very limited SQL-89 features but using them is generally considered crazy. They were added to the language in the dark ages for marketing purposes. You will be much more successful writing your query using the 4GL.
If you are actually trying to do this from within the 4GL then you are looking for the TODAY keyword.
Modern versions of Progress do support SQL-92 access via ODBC or JDBC. But you need to upgrade to get that.

Related

Inaccurate COUNT DISTINCT Aggregation with Date dimension in Google Data Studio

When I aggregate values in Google Data Studio with a date dimension on a PostgreSQL Connector, I see buggy behaviour. The symptom is that performing COUNT(DISTINCT) returns the same value as COUNT():
My theory is that it has something to do with the aggregation on the data occurring after the count has already happened. If I attempt the exact same aggregation on the same data in an exported CSV instead of directly from a PostgreSQL Connector Data Source, the issue does not reproduce:
My PostgreSQL Connector is connecting to Amazon Redshift (jdbc:postgresql://*******.eu-west-1.redshift.amazonaws.com) with the following custom query:
SELECT
userid,
submissionid,
date
FROM mytable
Workaround
If I stop using the default date field for the Date Dimension and aggregate my own dates directly in within the SQL query (date_byweek), the COUNT(DISTINCT) aggregation works as expected:
SELECT
userid,
submissionid,
to_char(date,'YYYY-IW') as date_byweek
FROM mytable
While this workaround solves my immediate problem, it sucks because I miss out on all the date functionality provided by Data Studio (Hierarchy Drill Down, Date Range filtering, etc.). Not to mention reducing my confidence at what else may be "buggy" within the product 😞
How to Reproduce
If you'd like to re-create the issue, using the following data as a PostgreSQL Data Source should suffice:
> SELECT * FROM mytable
userid submissionid
-------- -------------
1 1
2 2
1 3
1 4
3 5
> COUNT(DISTINCT userid) -- ERROR: Returns 5 when data source is PostgreSQL
> COUNT(DISTINCT userid) -- EXPECTED: Returns 3 when data source is CSV (exported from same PostgreSQL query above)
I'm happy to report that as of Sep 17 2020, there's a workaround.
DataStudio added the DATETIME_TRUNC function (see here https://support.google.com/datastudio/answer/9729685?), that allows you to add a custom field that truncs the original date to whatever granularity you want, without causing the distinct bug.
Attempting to set the display granularity in the report still causes the bug (i.e., you'll still set Oct 1 2020 12:00:00 instead of Oct 2020).
This can be solved by creating a SECOND custom field, which just returns the first, and then you can add IT to the report, change the display granularity, and everything will work OK.
I have the same issue with MySQL Connector. But my problem is solved, when I change date field format in DB from DATETIME (YYYY-MM-DD HH:MM:SS) to INT (Unixtimestamp). After connection this table to the Googe Datastudio I set type for this field as Date (YYYYMMDD) and all works, as expected. Hope, this may help you :)
In this Google forum there is a curious solution by Damien Choizit that involves combining your data source with itself. It works well for me.
https://support.google.com/datastudio/thread/13600719?hl=en&msgid=39060607
It says:
I figured out a solution in my case: I used a Blend Data joining twice the same data source with corresponding join key(s), then I specified a data range dimension only on the left side and selected the columns I wanted to CTD aggregate as "dimensions" (and not metric!) on the right side.

How can we use H2 to test SQL Server code that involves date to string conversions?

We use the H2 database engine as part of our test tooling for a product that uses SQL Server 2012 in production. Some of the existing SQL views use the three-argument CONVERT function on dates to format them as "ODBC Canonical" date:
CONVERT(VARCHAR, some_date, 120)
Normally when we encounter a situation like this we do one of the following two things:
we replace the SQL with something portable that works in MS SQL and H2
we implement a JAVA function to match MS SQL's behaviour and map it as UDF into H2
At the moment both seem to fail us since MS SQL doesn't seem to offer an alternative way of formatting dates and CONVERT is already a function in H2, just not in the three argument form.
We seem to be left with two options that we don't really like:
add a layer of in-direction on both sides, by defining a UDF in MS SQL that runs the convert, with a corresponding one in H2,
patch H2
The issue with the former is that it will introduce something into production that is solely for testing. That is true to some extent for migrating to more portable SQL as well, but adding the UDF is going a step further.
Patching H2 could be an option, but it is hard to tell how much effort that would be, in particular considering the existing CONVERT function. If suitable for a wider audience we would have to also cover MS SQL's weird world of styles across the types in a reasonable fashion, whereas we are only after one style for dates.
Is there another way? Has anyone experience with solving this problem?
The equivalent result using the FORMAT function is:
SELECT FORMAT(GETDATE(),'yyyy-MM-dd HH:mm:ss');
It seems that using the FORMAT function instead of CONVERT may resolve your issue.
Another way without using CONVERT is this:
SELECT
CAST(YEAR(GETDATE()) AS VARCHAR(4)) + '-' +
CAST(MONTH(GETDATE()) AS VARCHAR(2)) + '-' +
CAST(DAY(GETDATE()) AS VARCHAR(2))
(this is just an example and does not contain time components)

ssrs/ssrb end user picks a date to filter by

I'm using sql server 2008 r2 and i'm new to building reports with ssrs. I have the reports built, but i'm trying to make it so when the end user, goes to the report on the site, they are able to pick a start and end date. So the data gets filtered by those, to look at it each quarter.
I've been looking through the interwebs for a few hours and it looks like people are able to do this, but i haven't seen anything on how yet.
Also i see there is a date picker thats greyed out, but I've read that it can only be used in web projects, is that what I'm looking for?
I don't have 2008 but in 2012 you would simply define 2 parameters as date/time and amend your dataset to include them. For example
SELECT SalesOrderID, OrderDate, Status, TotalDue
FROM Sales.SalesOrderHeader
where orderdate between #lodate and #hidate
The datasource in this case is advicentureworks2012.
SSRS automatically adds the parameters to the report and includes a date picker.

Eclipse BIRT Timeline for one Day in minutes

I am building reports with Eclipse BIRT and got to a problem with the scales of the x-axis. I am getting my input with a select-string out of a database table. There I have events from a Nagios-log-file, with timestamps for every events begin and end. Out of them I create a time like hh:mm, this is enough, it doesn't have to have the seconds or the date (These I select somewhere else). For every event I get a 1 or a 0, representing up- and downtimes.
Now I want to built the report so that I have the scaling of the x-axis for all 1440 Minutes of the day, just changing the state (to 0) when there is a downtime. I've already tried to format the scale, but it doesn't work at all. After days of searching and 'try and error' I am now asking for help. Is there a way to format the chart the way I need and how could it be done?
The last idea of mine was to have another table with every minute inculded from which I select the data and to update this table with the event-data from the nagios-log-table, but this doens't seem to be an adequate solution. Maybe there is something simple I am just not able to see right now.
P.S.: I am fairly new in this and the eclipse manual did not help me with this specific problem. I also know that there are easy, simply and amazing ways to get those kinds of report out of nagios, but I have to do it with BIRT...
I finally found a way to get the report the way I needed.
I am joining my data_table with "generate_series" to get the missing data for every minute.
The postgresql statement looks like:
select *, coalesce(updown, 1)
from generate_series ('19.12.2015 00:00'::timestamp, '19.12.2015 23:59', '1 minute')
left join data_table
on date_trunc('minute',to_timestamp(date_ts)) = generate_series
and host like '%host%';
This may not be the best way to do it, but it worked for me and maybe it is also helpful for others. To usw this with BIRT I just replaced the host and the dates with the parameter-sgn "?".

Create a warning prompt box that appears before parameters are set in Crystal Reports

I have created a Crystal Report for some of my users with a date range parameter set. The volume of information that the SQL command returns means that anything over a 7 day period in the date parameter slows the report to unusable speeds and subsequently locks the DB for all other users.
Does anyone know of a way to create a prompt in Crystal Reports that will appear before the parameter set? I.e. As soon as they select the report and click "Open", the first thing they see is a box saying "Please ensure a maximum 7 day date period". Then upon clicking "OK" or something of my choosing, they are presented with the parameter fields and can continue with the report.
If this cannot be done, is there a way to restrict the parameters so that when the users select the start date, they can only select a maximum of 7 days after.
The other option, if it is doable, is to have them select the start date and then it auto complete the end date with a date 7 days after the start date.
At the moment i have just added (Must be a 7 day period) to the parameter title but i dont feel this does a good enough job at advertising it and as soon as i publish it i know someone will want to get 4/5 years worth of data...our clinicians will be most unimpressed if they PAS system locks up during a busy clinic.
I have attached a screenshot of the kind of thing i am after. It is a little crude as it was done in paint but it gets the point across.
I have searched high and low for this solution so i am not sure it even exists, but am asking out of sheer desperation.
Thanks in advance,
Mike
If you use Crystal Report solely (not within a program like .Net app) you can select your latest proposition. Get start date and in your SQL command (View, Stored Procedure, ...) select items from startDate to startDate + 7 days.
Depending on your DBMS there are ways to add some value to date (like dateadd function in MSSQL).
So its done.