Date Value Methods
Date fields are handled as strings in Studio SDK responses. The returned format is YYYY-MM-DD.
Assignment
const dueDate = String(payload.input.dueDate || '').trim();
await context.form.update({
recordId: 'record-id',
data: {
due_date: dueDate,
},
});
Accepted input examples:
| Input | Normalized Value |
|---|---|
'2026-06-18' | '2026-06-18' |
new Date('2026-06-18') | format before writing |
null | clear the field when allowed |
Constant Values
Date-related field types are written as strings. Time fields use HH:mm:ss; date, week, month, quarter, and year fields use YYYY-MM-DD.
For period fields, define the constant as the date that represents the period. Use the period start date to keep scripts predictable.
| Field Type | Constant Value | Meaning |
|---|---|---|
| Date | '2026-06-18' | June 18, 2026 |
| Time | '09:30:00' | 09:30 |
| Week | '2026-06-14' | The week that starts on June 14, 2026 |
| Month | '2026-06-01' | June 2026 |
| Quarter | '2026-04-01' | Q2 2026 |
| Year | '2026-01-01' | Year 2026 |
const defaultValues = {
date_value: '2026-06-18',
time_value: '09:30:00',
week_value: '2026-06-14',
month_value: '2026-06-01',
quarter_value: '2026-04-01',
year_value: '2026-01-01',
};
await context.form.update({
recordId: 'record-id',
data: defaultValues,
});
Do not write display labels as stored values.
const invalidPeriodValues = {
week_value: '2026-W25',
month_value: '2026-06',
quarter_value: '2026-Q2',
year_value: '2026',
};
Range and multiple-selection fields use the same item format.
const periodRange = ['2026-04-01', '2026-07-01'];
const selectedMonths = ['2026-06-01', '2026-07-01'];
Convert To Timestamp
const dateText = String(record.data.due_date || '');
const timestamp = new Date(`${dateText}T00:00:00`).getTime();
if (Number.isNaN(timestamp)) {
throw new Error('DUE_DATE_INVALID');
}
Date Operations
function formatDate(value: Date) {
const year = value.getFullYear();
const month = String(value.getMonth() + 1).padStart(2, '0');
const day = String(value.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
}
const today = formatDate(new Date());
const tomorrowDate = new Date(`${today}T00:00:00`);
tomorrowDate.setDate(tomorrowDate.getDate() + 1);
const tomorrow = formatDate(tomorrowDate);
Use string comparison only when both values use the same YYYY-MM-DD format.
const overdue = String(record.data.due_date || '') < today;