I'm trying to show todays date as the default value in a select date.
INITIALIZATION.
select-OPTIONS: so_date FOR sy-datlo.
START-OF-SELECTION.
so_date-sign = 'I'.
so_date-option = 'BT'.
so_date-low = sy-datum.
so_date-high = sy-datum.
APPEND so_date.
This isn't working though. Any ideas?
You must set the value before START-OF_SELECTION:
select-OPTIONS: so_date FOR sy-datlo.
INITIALIZATION.
so_date-sign = 'I'.
so_date-option = 'EQ'.
so_date-low = sy-datum.
CLEAR so_date-high.
APPEND so_date.
Did you try the easy version:
select-OPTIONS: so_date FOR sy-datlo default SY-DATUM.
I think it should work (can't test is actual).
Related
I made a few functions with GoogleSheets using AppsScripts for simple task a few times in previous years. I always had problems when taking dates from cells/ranges and processing them, but somehow alwaays found a workaround, so that I did not have to deal with it. Well, this time I can not find a workaround, so I will try to explain my problems with the following code:
function getDates(){
var s = SpreadsheetApp.getActiveSpreadsheet();
var sht = s.getSheetByName('Dates');
var date = sht.getRange(2,1).getValues();
Logger.log(date[0][0]); //output is Tue Jun 08 18:00:00 GMT-04:00 2021
var datumFilter= Utilities.formatDate(date[0][0], "GMT+1", "dd/mm/yy");
Logger.log(datumFilter); //output is 08/00/21
var outrng = sht.getRange(25,1);
outrng.setValue(date);
}
The first targeted cell ('var date') has a value of "9.6.21" in the spreadsheet. The cell is formatted as a date and it opens a calendar when double-clicked. When I set the new cells values (with 'outrng.setValue(date);'), the result is OK, with the same date as in the original cell.
But I do not need to simply transfer the values, I want to implement them in some loops and I have no idea how to simply get the date in the same format or at least the same date in the script as it is in the cell. As you can see from the logger, the values there are different. A simple d/m/yy format would be sufficient.
My spreadsheet settings are set to my local time (Slovenia, GMT+1).
I am guessing that I am missing some basics here. I have spent many hours trying to understand it, so any help is highly appreciated!
Cooper already answered all your questions in the comment. I'd like to add on and show you an example on what it would like and add some modifications.
Code:
function getDates() {
var s = SpreadsheetApp.getActiveSpreadsheet();
var sht = s.getSheetByName('Dates');
// get last row of the sheet
var lastRow = sht.getLastRow();
// get your sheet's timezone
var timezone = SpreadsheetApp.getActive().getSpreadsheetTimeZone();
var output = [];
// getValues is mostly used for multiple cells returning a 2D array
// use getValue for single cells to return its actual value
// but since function name is getDates, I assume column A is all dates
// so we fetch the whole column (A2:A[lastRow]) except the header
var dates = sht.getRange("A2:A" + lastRow).getValues();
// for each date on that column, we format the date to d/M/yy
// m/mm = minute
// M/MM = month
dates.forEach(function ([date]){
Logger.log(date);
var datumFilter= Utilities.formatDate(new Date(date), timezone, "d/M/yy");
Logger.log(datumFilter);
// collect all dates in an array
output.push([datumFilter]);
});
// assign all the dates in the array onto range B2:B
sht.getRange(2, 2, output.length, 1).setValues(output);
}
Sample data:
Logs:
Output:
Note:
The output on sheets is not equal to logs due to the formatting of my sheet.
I'm trying to pass a date to a function in Kotlin. I don't want to have to type "08/30/2018" as a String and would instead prefer Date. I initially tried just 08/30/2018 but get a compiler stating an Integer was found for the input rather than Date.
var myDate = 1/1/2000
var newDate = 08/30/2018
fun setDate(value: Int){
myDate = value
}
setDate(newDate)
println(newDate) //0
println(myDate) //0
println(myDate.compareTo(newDate)) //0
Why does Kotlin accept 08/30/2018 as an int? Why is it stored correctly to another int variable but then print 0 when the value is retrieved?
How can I initialize a variable to a date like 1/1/2000 and then set another date later on? I haven't found anything about passing a date anywhere unless it is a String.
When you assign 8/30/2018 to a variable then the compiler recognizes it as integer division 8/30 which is 0 and then /2018 and the result is 0.
You could do it like val date = Date("1/1/2000") but this is now deprecated
You can use the Java 8 Date/Time API instead:
val date = LocalDate.of(2000, 1, 1)
you can find more here:
https://www.oracle.com/technetwork/articles/java/jf14-date-time-2125367.html
I am trying to create a OCCI::Date object using setDate method but I get an error while doing so.
Below is the snippet of my code.
using ODate = oracle::occi::Date;
ODate ts;
ts.setDate(datetime.year(),datetime.month(),datetime.day(),datetime.hour (),datetime.minute(),datetime.second());
this is the error I get - ORA-32146: Cannot perform operation on a null date
I also printed the values that I am passing to setDate method to check if those values are correct and they are all fine and within the Date range.
datetime.year() = 2018
datetime.month() = 6
datetime.day() = 5
datetime.hour() = 6
datetime.minute() = 1
datetime.seconds() = 22
Any leads to resolve this issue?
Oracle has its own format of storing date. Check this link.
Set the resulted value in OCIDate.OCIDateYYYY
I have the following code returning the time in a 24 hour format like "13:10:23"
DateTime.DateFormat = "h:mm a"
now = DateTime.Now
t = DateTime.Time(now)
lblCurrentTime.Text = t
But I'd like to have the format in hours:minutes:seconds:milliseconds
Unfortunately, the link to the supported formats from this page is broken..
http://www.basic4ppc.com/android/wiki/index.php/DateTime
Could anyone please suggest how to use DateTime.Dateformat to return a time value to millisecond resolution?
Thank you, but I'm afraid it's still returning time in the format: "23:11:09"
Perhaps my variables are incorrect?
Sub Time_tick
Dim now As Long
Dim t As String
DateTime.DateFormat = "HH:mm:ss:SS"
now = DateTime.Now
t = DateTime.Time(now)
lblCurrentTime.Text = t
End Sub
Here is the correct link.
Try: "HH:mm:ss:SS"
Note that you should use DateTime.TimeFormat and not DateFormat.
Can you try the following ?
DateTime.DateFormat = "HH:mm:ss:SS"
I have datagrid with two datagridviewcombo column, one column is dynamic fill and one has fixed hardcoded values.
The problem is I can't set the value of dynamic GridViewComboBox, when I try to set it generates continues errors.
System.FormateException: DataGridViewComboBoxCell Value is not valid.
My code to load the grid is
Dim dt As DataTable
dt = GetDataTable("Select valuecol,displayCol From mytable") 'GetDataTable gives me datatable
cmbAntibiotics.DataSource = dt
cmbAntibiotics.DisplayMember = "Antibiotics"
cmbAntibiotics.ValueMember = "AntibioticsID"
Dim Index As Integer
Dim dgr As DataGridViewRow
For Each dr As DataRow In dtFromDB.Rows 'This datatable is filled with database
Index = dtFromDB.Rows.Count - 1
GRDAntimicrobials.Rows.Add()
GRDAntimicrobials.Rows(Index).Cells("cmbAntibiotics").Value = dr("AntibioticsID").ToString 'At this point it shows value (1,2,3) rather then showing its display members
GRDAntimicrobials.Rows(Index).Cells("AntibioticsStatus").Value = dr("AntibioticsStatus").ToString
Next
Pls help with me
It seems like you're trying to assign the value to whatever there is on the cell rather than instantiate the object that resides in the cell and then assign its value. I would try something like this:
Dim vComboBoxColumn As DropDownList = DirectCast(GRDAntimicrobials.Rows(index).Cells("cmbAntibiotics"))
vComboBoxColumn.Value = dr("AntibioticsStatus").ToString