Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Jalali Convert date in scripting

Topic Labels: Scripting extentions
181 1
cancel
Showing results for 
Search instead for 
Did you mean: 

I want use scripting app for convert gregorian calender to jalali calender.
I have a field named as ''date" for Gregorian and an empty field named as"Jalali" for result of code.
for convert I want use of this code:
//
let day = new Date().toLocaleDateString(‘fa-IR-u-nu-latn’);

console.log(day);
//
But I don’t know how to put field names in the code!
and also I want the result, entry in jalali field.

1 Reply 1
const table=base.getTable('YOURTABLE');
const jal=r=>({'Jalali':new Date(r.getCellValue('date')).toLocaleDateString('fa-IR-u-nu-latn')})
const upd=await table.selectRecordsAsync({fields:['date']}).then(q=>q.records.map(r=>({'id':r.id,'fields':jal(r)})))
while(upd.length) await table.updateRecordsAsync(upd.splice(0,50))```