I have two editable time/date fields, TimeIn and TimeOut, and one computed for display field hoursWorked, what it does is get the difference between TimeIn and TimeOut and display it in hours:minutes, e.g (02:30 hrs). I decided to have another editable time/date fieldTimeIn_1 and TimeOut_1 field and computed for display field hoursWorked and another computed for display field totalHours, which displays the total/sum of hours of hoursWorked and hoursWorked_1. I tried this code:
thours:=#If(hoursWorked=null | hoursWorked_1=null; #Return(""); "" );
seconds := hoursWorked+hoursWorked_1;
hours := #Integer(seconds/3600);
minutes := #Integer(#Modulo(seconds;3600)/60);
output := #Right("00" + #Text(hours); 2) + ":" + #Right("00" + #Text(minutes); 2);
#TextToTime(output)
but nothing happens. Can you help me?
I assume that you calculated your fields hoursWorked and hoursWorked_1 the same way like in this formula shown. If that is the case, the fields hoursWorked and hoursWorked_1 are from type "Date/Time" in document no matter how you define the fields in form.
That's why your formula should look like this:
thours:=#If(#IsNull(hoursWorked) | #IsNull(hoursWorked_1); #Return(""); "" );
nullTime := #ToTime("00:00");
seconds := (#ToTime(hoursWorked) - nullTime)+ (#ToTime(hoursWorked_1) - nullTime);
hours := #Integer(seconds/3600);
minutes := #Integer(#Modulo(seconds;3600)/60);
output := #Right("00" + #Text(hours); 2) + ":" + #Right("00" + #Text(minutes); 2);
#TextToTime(output)
Only first three lines are different to your formula.
I don't believe the first test of hoursWorked=null is correct. I think you need #IsNull(hoursWorked). That said I would think the result would still be false and the formula would continue.
It might be worthwhile to see just what output produces without the #TextToTime.
Related
I am attempting to have phpexcel set the range for $objValidation based off a variable so not to have null values in my dropdown. This was my code
$objValidation->setFormula1('Index!$A$5:$A'.'count(Index!$A$5:$A$200');
which resulted in additional blank/null values in my dropbox making it bigger than need be. what I would like to do is something like this
$sql_temp = "SELECT `tempID`,`serialNUM` FROM `temp_sensor_specs` WHERE `statusTYPE`='SPARE'";
$result_temp = mysqli_query($link, $sql_temp);
$row_temp = mysqli_fetch_all($result_temp,MYSQLI_NUM);
$objPHPExcel->getActiveSheet()->fromArray($row_temp,null,'A5');
$count_temp = count($row_temp) + 4;
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B4')->getDataValidation();
$objValidation->setType(PHPExcel_Cell_DataValidation::TYPE_LIST);
$objValidation->setErrorStyle(PHPExcel_Cell_DataValidation::STYLE_INFORMATION);
$objValidation->setAllowBlank(true);
$objValidation->setShowDropDown(true);
$objValidation->setErrorTitle('Input error');
$objValidation->setError('Value is not in list');
$objValidation->setFormula1('Index!$A$5:$A$count_temp');
So that didn't work I've also tried it in several variations as such
$objValidation->setFormula1('Index!$A$5:$A'.'$count_temp');
$objValidation->setFormula1('Index!$A$5:$A'.count($row_temp) + 4);
$objValidation->setFormula1('Index!$A$5:$A'$count_temp);
I really feel I've used syntax incorrectly, but can't figure out how. I've done similar range setting in loops for( $i=4; $i<=15; $i++ ){
$objValidation = $objPHPExcel->getActiveSheet()->getCell('B'.$i)->getDataValidation(); but also don't think this needs to be looped it should be a simple count and set that value as the count return +4 (as my dropdown starts on cell row 5)
thanks in advance
So the proper syntax ended up being `$objValidation->setFormula1('Index!$A$5:$A'."$count_temp");
I have a date/Time field in my LN doc. The date stored as "11/09/2014 11:04:25 ZE4". I want to patch the same with 11/09/2013 11:04:25 ZE8.
How to do it through formula language ??
text := #LeftBack(#Text(myDateField; "D0T0Z2"); " ");
date := #TextToTime(#Left(text; " "));
time := #TextToTime(#Right(text; " "));
result := #TimeMerge(date; time; "Z=-8");
FIELD whatever := #ToTime("4/15/2020 5:46:13 AM ZE8");
I have a view with a column that contains string field and i want to remove all zeros (0) before the first character, from left to right, different from 0 without modify then value of the field, so i have to use a formula in the column...
For example:
00120dn3 --> in the column i want to see 120dn3
000000001r --> in the column i want to see 1r
191ds5000 --> in the column i want to see 191ds5000
the string lenght varies....
there is someone can help me ?
i use lotus notes 6.5.6
Use the #Right function as long as there is a leading "0":
_str := "00120dn3";
#While(#Left(_str; 1) = "0";
_str := #Right(_str; "0"));
_str
I have two dialoglist fields Cutt_Start and Cutt_End, both of the fields has example choices of: January | 1
February | 2
March | 3
...
December | 12
Now, what I want to happen is that, when you select January on the Cutt_Startand March on the Cutt_End, it should prompt an error that Month2 should be next to Month1. I tried this code, but nothing happens.
If Cutt_Start = "January" & Cutt_End <> "February" Then
Msgbox "Month2 should be next to Month1"
Else
Msgbox "January to February selected"
End If
Can you help me?
As already mentioned, the stored field values are the ones right of the pipe. BUT: such fields are always text- fields!!!!
To do a computation, you need to transform the text to numbers...
_start := #TextToNumber( Cutt_Start );
_end := #TextToNumber( Cutt_End );
_res := _end - #Modulo(_start; 12)
#If( !#IsError(_res) &_res != 1; #Failure( "your message" ); #Success)
This goes into the field validation of the Cutt_end- field.
If you need LotusScript (to have it in the QuerySave or the OnChange-Event of the field, then the code would be:
Option declare
Dim ws as New NotosUiWorkspace
Dim doc as NotesDocument
Set doc = ws.CurrentDocument.Document
If Cint(doc.Cutt_End) - CInt(doc.Cutt_Start) <> 1 then
messagebox "your Message"
End if
This code does NOT contain any errror handler.
And as mentioned in the other comments: this for sure is not the right way to do it. If cut_end always has to be one month later, then simply change it to computed and write as value:
#If(Cutt_Start = ""; ""; #Text(#Modulo(#TextToNumber( Cutt_Start ); 12) + 1))
Then you would not need to make your check...
The number to the right of the pipe character is the value of the field. The name to the left of the pipe is what is displayed to the user.
So if you just test that the numbers are sequential, and add a special case for Dec to Jan (1 comes after 12) then you should get the result you are looking for.
Note that the number value is still in text format so you'll need to cast it to a number first
If Cutt_End - Cutt_Start <> 1 Then Msgbox "Error!"
That said, if the Cutt_End must always be 1 month after Cutt_Start, then why have that field at all? Just calculate that field and make the user just choose the start month.
Please check the following and put your code into the onchange event. For web and the notes client the onchange function behavior is different.
Good morning!
I'm hoping someone can help me with what is probably a simple question but I just cant get things to work the way I would like. I am currently working with a report that has a "catch-all" text field. In this field the user can input anything they want, and on occasion, will input information in a column format (ex. 1.1). This field allows carriage returns which are used to create "rows" in this field. The problem is that the user wants the "columns" in this field to line up on the report without having to count spaces between the columns when the information is entered (ex. 1.2). The problem is that even when this type of information is entered there is no set protocol or formatting guidelines. There may be multiple "subtitles", rows, rows separated by subtitles, etc.. The carriage return (Chr(10)) at the end of each line (or beginning of each new line) is the only thing that can be relied on consistantly.
I am currently trying to seperate each individual row, format each as desired, and put it back together like so:
Dim output As String
Dim sections as String
Dim returnCount as Int
Dim leftText as String
Dim rightText as String
Dim sectionTogether as String
Dim totalText as String
Dim textLength as Int
output = {table.textfield}
sections = ExtractString(output, Chr(10), Chr(10))
If Instr(sections," ") > 0 Then
leftText = Left(sections, Instr(sections, " "))
textLength = Length(Left(sections, Instr(sections, " "))
rightText = Right(sections, Instr(sections, " "))
Replace(sections," "," ")
sectionTogether = rightText + (Space(20) - (textLength - 3)) + leftText
totalText = totalText + sectionTogether
formula = totalText
else
formula = output
This is the gist of what I'm trying to do. A couple of notes:
1) I know I am missing a loop of some kind to format every section but I dont know how to set that up in crystal
2) I have VB programming experience, but I am noob in crystal and its limited tools so I feel hamstringed and I'm having trouble finding the methods and tools I would use in Visual Studio
3) My syntax may also be off in a few places because I am still learning how to set this up and I REALLY miss a debugger.
I hope someone can help me, I have been researching for over a week and it feels like I'm just beating my head against a wall.
Thank you in advance.
The output examples
ex. 1.1
"Your current charges are:
Jan 12.89
Feb 117.44
Mar 15.02
Apr 4.17"
ex. 1.2
"Your current charges are:
Jan 12.89
Feb 117.44
Mar 15.02
Apr 4.17"
The first thing you're going to want to do is split up your rows via split(), like this:
local stringvar array wallOText := split({table.textfield},chr(10));
This will give you an array of strings where each array entry is a "row". Now you can loop over your rows with the following:
for i := 1 to ubound(wallOText) step 1 do <some stuff to wallOText[i]>
Now, getting the columns right-justified is a little trickier, but here's some code to get you started. You can adjust the column widths to whatever you may need (in this case, 20 spaces). Also note, you have to use a fixed-width font.
local stringvar output;
local stringvar array row;
local numbervar i;
local numbervar j;
local stringvar array wallOText := split({#some text},chr(10));
local stringvar elem;
for i := 1 to ubound(wallOText) do //loop over lines
(row := split(wallOText[i]," ");
for j := 1 to ubound(row) do //loop over words
(elem := trim(row[j]); //get current element and cut white space
if not(elem="") then
output := output + space(20-len(elem)) + elem); //build output string
output := output + chr(10));
output