Hı,
I want to fill it with data in the excel table that is not found somewhere. but the field is write protected. only date selection can be made. I found an object on the selection screen, when I change this value, the date I want comes up, but I don’t know how to transfer the data to this value from Excel. The field I marked in red in the picture indicates the day of the date.
@erdincdere You can concatenate a date from pieces making up the day, month and year. You would then read in your day (or month) from Excel and then insert it into the appropriate part of the date concatenation.
Date todaysDate = new Date();
def dayPart = todaysDate[Calendar.DAY_OF_MONTH];
def monthPart = todaysDate[Calendar.MONTH] + 1;
def yearPart = todaysDate[Calendar.YEAR] ;
def myDate = monthPart.toString() + “/” + dayPart.toString() + “/” + yearPart.toString();
You need the + 1 for the month to get the current date.
In this case, I want the date in the format: m/d/yyyy. Rearrange the concatenation if you need a different date format.
If you want to have the date format as mm/dd/yyyy, then you can add:
def dPart = (dayPart < 10) ? “0” + dayPart.toString() : dayPart.toString();
def mPart = (monthPart < 10) ? “0” + monthPart.toString() : monthPart.toString();
def theDate = mPart + “/” + dPart + “/” + yearPart.toString();
If you copy and paste from this forum, you need to change all smart quotes, which have curves or curls to them, to straight quotes.
1 Like