use EXIF date for date field

Viewing 1 reply thread
  • Author
    Posts
  • May 15, 2026 at 11:17 AM #54120

    FrAnksch
    Participant

    Can anybody give me a script that reads the EXIF date of a photo (used in field “photo”) and puts this date to an separate field “date”?

    I want the entries to be ordered by the date of the photos, that are used in the records.

    THABK YOU!

    May 16, 2026 at 8:50 PM #54131

    Daniel Leu
    Participant

    Following field script should do the trick. It assumes that the field name is photo. Don’t forget to set the return type of the field script to date.

    
    function First_Photo_Date() {
        // set field name according to your form
        var photo_id = form.getFieldNamed('photo').getId();
    
        // get attached photos
        const photos = record.getFieldValue(photo_id);
    
        // get first photo's date
        const photoExif = photos[0].getExifData(photos[0]);
        const photoDate = photoExif['DateTimeOriginal'];
    
        // handle Exif date format
        const [datePart, timePart] = photoDate.split(" ");
        const [year, month, day] = datePart.split(":").map(Number);
        const [hour, minute, second] = timePart.split(":").map(Number);
    
        // create date object
        const date = new Date(year, month - 1, day, hour, minute, second);
        
        return date;
    }
    
    First_Photo_Date();
    

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

Viewing 1 reply thread

You must be logged in to reply to this topic.