How to format timevalue to HH:MM:SS in datalabel - graph

So i have a bar graph in crystal reports. On this graph i have a data label attached to each of the graphs that displays the value of the graph in seconds, which appears like so:
What i would like to do is format this data-label into a time formatting. So for each bar in the graph it would have the data-label appear in the following format:
HH:MM:SS.
i am able to get the time formatting to appear using the following formula:
local NumberVar Sec;
local NumberVar ss;
local NumberVar mm;
local NumberVar hh;
local StringVar SSS;
local StringVar MMM;
Sec := Sum ({GetAlarmSummaryDataSet2Response/GetAlarmSummaryDataSet2Result/Items/AlarmSummaryItem2.StopTime}, {GetAlarmSummaryDataSet2Response/GetAlarmSummaryDataSet2Result/Items/AlarmSummaryItem2.Section}) ;
hh := Int (Sec/3600);
mm :=Int ((Sec/60)- (60* Int(Sec/3600 )));
If mm<10 then MMM := "0" & ToText (mm,0);
If mm>9 Then MMM := ToText(mm,0) ;
ss :=Sec-(3600 * hh ) - (60 * mm ) ;
If ss<10 then SSS := "0" & ToText (ss,0);
If ss>9 Then SSS := ToText(ss,0) ;
ToText ( hh,0) & ":" & MMM & ":" & SSS
But what i am unsure of is how to implement this formula onto a data label.
Any help or suggestions are greatly appreciated.
Thank you

You can choose to display the group name, and you can display and format the summarized value calculated by the chart, but you can't provide a custom formula. It just isn't possible using the chart library in CR XI.
My eventual workaround for this problem:
Modify the value formula to eliminate the aggregate function. (This is necessary because Crystal won't allow an aggregate function in a group name field -- see #2.)
For the group name, specify a formula with the text you want to display in the riser. Include both the label and the formatted value, separated by Chr(13) & Chr(10) to place them on separate lines.
Configure the riser to display the label, not the value.
To apply this to your problem you'd need to make these changes:
Eliminate the aggregate function. Of course I don't know if this will be possible using your setup. Perhaps if you're using a DBMS you could use a SQL command or a stored procedure to calculate the sum before the data reaches Crystal.
Print the label and value together, either on the riser or the X-axis.
If that's not good enough for your application, you might consider CRChart, a commercial replacement which tries to address the sometimes-crippling limitations of Crystal's chart library. (I thought it was too pricey.) I think the #APPEND_DATATEXT macro would let you place a custom value on a riser, but you'd still need to move the summary to the server.

Related

Pine Script Issue Percentage Change

I am trying to create a normalized percentage change script on the interaday charts, identical to the percent setting when clicking the bottom left gear button and then clicking "percent" in the tradingview chart, allowing the user to compare two securities accumulated price movement expressed in terms of percentages on any given timeframe in this case I am using duration of only 1 day with 1 minute bars. In python it would be similar to the .rebase() function or .pct_change() function.
My Current Issues
The first is that the percentage return being returned from the script does not replicate the percentage return shown on the graph for SPY.(Although the shape of the SPY indicator line generated by the script does match the SPY line just that the value as shown in the below pictures does not match.)
My script does not start at some indexed (ie. normalized value) lets say 0% when including another security to the script. To explain my issue easily I have only included one security within the code below for this post.
CODE
First Attempt using the ta.change() function
//Using the change() function
//#version=5
indicator("var float accum_base", format = format.percent, overlay=false)
// Add the script's inputs
symb3 = input.symbol(title="SPY", defval="AMEX:SPY")
//Retrieve Symbol Price Data
SPY = request.security(symb3, timeframe.period, close)
//Percentage Change Calc
change = ta.change(SPY, 1) / SPY[1]
//acum method to accumulate all percentage changes from first bar
var float accum = na
accum := nz(accum + change)
plot(accum)
Using the ta.change() function script SPY returns -0.12% vs the displayed SPY return of -1.66%
Second Attempt using the ta.roc() function
//#version=5
indicator("roc function", format = format.percent, overlay=false)
// Add the script's inputs
symb3 = input.symbol(title="SPY", defval="AMEX:SPY")
//Retrieve Symbol Price Data
SPY = request.security(symb3, timeframe.period, close)
//Percentage Change Calc
base = ta.roc(SPY, 1) / SPY
//Acummulated Percentage Change
var float accum_base = na
accum_base := nz(accum_base + base)
plot(accum_base, title= "SPY", color=color.purple)
Second attempt using the ta.roc function the script SPY returns -0.03% vs the displayed SPY return of -1.66%
I have tried everything and could not resolve the issue. Any help would be greatly appreciated!

Access 2007 - Referring to sub-report value from sub-sub-report

I have a report that has several sub-reports as well as a sub-report to one of the sub-reports.
The one that concerns me:
rptProgressReport ->rptEmployee (sub of rptProgressReport) -> rptSubEmployeeProject (sub of rptEmployee)
So far everything is generating as needed. Employees list in order, and the sub-report pulls out various project details. Except I need to add together time spent from one table.
tblProject (main table) -> tblProjectHistory (related table to tblProject via projectID->fldProjectID).
tblProjectHistory has the following fields.
[historyID],[fldProjectID], [History Information], [History Date], [Time Spent], [Employee].
I need to do a sum of all [Time Spent] for projects that equal what is being displayed and as long as the employee matches and the date is within the specified date range.
Specified date range is via the launching Form (frmReportGeneration) with fields txtStartDate and txtEnd Date.
Sub-report rptSubEmployeeProject has a text box (txtTimeSpent) that I have the following for a control source.
=Sum(DLookUp("[Time Spent]","tblProjectHistory","[Employee]='" & [Reports]![rptEmployee].[txtTempEmployee] & "' AND [History Date] > " & [Forms]![frmReportGeneration].[txtStartDate] & " AND " & [History Date]<" & [Forms]![frmReportGeneration].[txtEndDate] & "))
the rptEmployee field of txtTempEmployee correctly displays the current employee to match in that sub-report.
The problem is I get prompted for each value part of the above code - txtTempEmployee and txtStartDate/txtEndDate, even if I change the report value to be [Reports]![rptProgressReport]![rptEmployee].[txtTempEmployee]
Any idea how to correctly pull variables from the parent report or the first sub-report?
Thank you.
+++++ Update +++++
Okay update/close on this. I ended up needing to do something similar to what was suggested in the accepted answer. I could not get the idea posted to work - but i was able to set tempvars in vba and used those throughout the report/sub-report(s).
it is not recommended to refer to other objects via this construct "Forms!...." (or "Reports!...")
i made some bad experience with it. i suggest to put the values into a variable and make a
Get-Funktion:
in a Module you define:
Publicg dtStart As Date
Public gdtEnd As Date
in the form you assign the start and end date in the button where you fire the report
gdtStart = Me!txtStartDate
gdtEnd = Me!txtEndDate
now the Get-Function:
Public Function Get_Date_Start () As Date
Get_Date_Start = gdtStart
End Function
Public Function Get_Date_End () As Date
Get_Date_End = gdtEnd
End Function
in the Query you can use it now like this:
... AND [History Date] > " & Get_Date_Start() & " AND " & [History Date] <" & Get_Date_End()
BTW: don't use spaces in any object-name: instead of [History Date] name it History_Date, you can avoid Brackets in Code :-)

Parse alfresco date

I'm developing a custom validator of a date input in my workflow form and I get a null after parsing a date this is what I done:
// check dates can be parsed
str_expiryDate = field.form.prop_wfbxTestWorkFlow_NfDate.value;
console.log("Non conformite"+str_expiryDate);
str_reminderDate = field.form.prop_bpm_workflowDueDate.value;
console.log("echeance"+str_reminderDate);
Alfresco.logger.warn("Expiry Date: " + str_expiryDate + " | Reminder Date: " + str_reminderDate);
d_expiryDate = Date.parse(str_expiryDate);
console.log("nfDate"+str_expiryDate);
d_reminderDate = Date.parse(str_reminderDate);
console.log("Date echéance"+d_reminderDate);
and then i get this in console:
Non conformite2013-06-21T00:00:00.000+01:00 echeance2013-06-09T00:00:00.000+01:00
nfDatenull
Date echéancenull
How I can parse these two dates and then compare it? .thanks
Use Alfresco.util.fromISO8601(date)
According to the client-api docs
Convert an ISO8601 date string into a JavaScript native Date object
You are parsing the "value" of a date, not the date itself.
The best way to compare is, imho, using the format YYYYMMDD, and than compare it as a number.
Something like this (there is sure a far more elegant way to do that, but at this time it's the only one that got me):
var indexDate=str_expiryDate.indexOf("-");
var dayDate=str_expiryDate.substring(0, 2);
var monthDate=str_expiryDate.substring(3, 5);
var yearDate=fromData.substring(6, str_expiryDate.length+1);
int dataNew=yearDate+monthDate+dayDate;
and than compare the two dates value.
Obviously check if the index value are correct, I didn't double checked them.
Hope il helps.

TimeValue equivalent for periods longer then 24 hours

in my database the time someone has worked is stored in a certain amount of minutes. In my report I list those minutes in the format HH:MM. I do this by making use of the following function:
Function (numberVar numberToBeConverted)
local TimeVar result;
local StringVar hh := ToText((Truncate( numberToBeConverted ) / 60), "0");
local StringVar mm := ToText((Truncate( Abs(numberToBeConverted) ) mod 60), "00");
local StringVar ss := '00';
Local StringVar t:= hh + ":" + mm + ":" + ss;
if istime (t)
then result := TimeValue (tijd)
else result := TimeValue ("23:59:59");
result
I would like to preserve the datatype (time) but would like to be able to list duration longer then 24 hours (i.e. a workweek).
is this possible?
thanks
Unfortunately, CR's time format doesn't support what you want to do. Try my ElapsedTime() custom function, instead.
** edit **
If the field returns the # of seconds, you could make use of its Display String formula. Right click the field, choose 'Format Field...', then the 'Common' tab, then the button to the right of the 'Display String:' text; enter the following text:
//CurrentFieldValue assumed to be in seconds
ElapsedTime(CurrentFieldValue)
With this approach, you'll be able to have the formatting that you desire and still be able to use the field itself in calculations.

Compare date only (without time) in JPA2 (JPQL)

Im trying to compare Calendars with JPA2. The query looks somewhat like that:
TypedQuery<X> q = em.createQuery("select r from Record r where r.calendar= :calendar", X.class);
Calendar c = foo(); // setting fields and stuff
q.setParameter("calendar", c);
This, however, compares the date + time. I want to know if MM:DD:YYYY is equal and do not care about the time. Is there a nice way to do that in JPA2 or do I have to create a native query?
I tried setting HH:MM:SS:... to zero before saving it in the db but I don't know if this is very wise, regarding time zones and daylight saving and stuff.
q.setParameter("calendar", c, TemporalType.DATE)
You can pass the TemporalType.DATE to setParameter method to truncate the date+time.
There is no mention of DateTime functions allowing to do that in the spec of JPQL, but you could always cheat and do
select r from Record r where r.calendar >= :theDayAtZeroOClock and r.calendar < :theDayAfterAtZeroOClock
Mysql and H2 compatible comparison of dates ignoring time part:
`#Query("SELECT DISTINCT s " +
"FROM Session s " +
"JOIN s.movie m " +
"WHERE m.id = :movie AND CAST(s.time AS date) = CAST(:date AS date) " +
"ORDER BY s.time")
List<Session> getByMovieAndDate(#Param("movie") Long movie, #Param("date") LocalDateTime date);`
When using an Oracle database, you can use the trunc function in your JPQL query, e.g.:
TypedQuery<X> q = em.createQuery("select r from Record r where trunc(r.calendar) = trunc(:calendar)", X.class);
See also https://cirovladimir.wordpress.com/2015/05/18/jpa-trunc-date-in-jpql-query-oracle/
I had to use date_trunc on the where clause:
TypedQuery<X> q = em.createQuery("select r from Record r where date_trunc('day',r).calendar= :calendar", X.class);
Calendar c = foo(); // setting fields and stuff
q.setParameter("calendar", c, TemporalType.DATE);
In Hibernate 6 and above, you can use date_trunc(text, timestamp) to truncate the timestamp more precisely, for example:
date_trunc('hour', timestamp) to truncate the timestamp up to the hour (no minutes and no seconds).

Resources