Jump to content
  • 0

Default date field to yesterday




I am able to set a date field on a datapage to today's date by setting the field's External Parameter to [@cbTimeStamp*] but what I need to do is set it to yesterday. So something like: Dateadd(day,-1, '[@cbTimeStamp*]') but you can't put a formula in the external or default parameters. Does anyone know of a solution for this?


Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

In case anyone else has this requirement I used some script in the end...



// Get today's date
var today = new Date();

// Calculate yesterday's date
var yesterday = new Date(today);
yesterday.setDate(today.getDate() - 1);

// Format yesterday's date as mm/dd/yyyy
var month = yesterday.getMonth() + 1;
var day = yesterday.getDate();
var year = yesterday.getFullYear();

var yesterdayFormatted = month + '/' + day + '/' + year;

// Set the value of the date input field to yesterday's date
document.getElementById('cbParamVirtual12').value = yesterdayFormatted;


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...