Copy link to clipboard
Copied
Hello everyone,
I need help please.
I have three fields
the first ist the lenthe of the embryo (LCC)
the seconde is the gestationnel age (Terme LCC)
the thrird is the date of conception (DG LCC)
when I choose the lenthe (LCC) of 10,2 mm that gives me (Terme LCC) 7 weeks
i need to calculate the date befor 7 weeks
every time i change the lenthe the Terme LCC changes
help please
So whatever number is in "Terme LCC" that many weeks should calculate?
If yes to above, use this as 'Validation' script of "Terme LCC" field and change "dd-mmm-yyyy" to whichever date format you want:
var date = new Date();
if(event.value == "")
this.getField("DG LCC").value = "";
else {
var str = event.value;
var n = str.match(/\d/g);
var num = n.join("");
date.setDate(date.getDate() -num*7);
this.getField("DG LCC").value = util.printd("dd-mmm-yyyy", date);}
Try this:
var date = new Date();
if(event.value == "")
this.getField("DG LCC").value = "";
else {
var str = event.value;
var n = str.match(/\d/g);
var nw = n.join("");
var num = nw.slice(0, -1);
var numday = str.match(/(\d+)(?!.*\d)/g);
date.setDate(date.getDate() -(Number(num)*7-14+Number(numday)));
this.getField("DG LCC").value = util.printd("dd-mmm-yyyy", date);}
Copy link to clipboard
Copied
I wanted to add that the count from current date
Copy link to clipboard
Copied
So whatever number is in "Terme LCC" that many weeks should calculate?
If yes to above, use this as 'Validation' script of "Terme LCC" field and change "dd-mmm-yyyy" to whichever date format you want:
var date = new Date();
if(event.value == "")
this.getField("DG LCC").value = "";
else {
var str = event.value;
var n = str.match(/\d/g);
var num = n.join("");
date.setDate(date.getDate() -num*7);
this.getField("DG LCC").value = util.printd("dd-mmm-yyyy", date);}
Copy link to clipboard
Copied
thank you very much.
I'm gratfull for you
it works but I made a mistake
how can I count days also
and how can substract 2 weeks from the resultat
exemple the age is 6 weeks + 1 days => date of conception is 25 / 01 / 2022 (from current date)
thanks alot
Copy link to clipboard
Copied
Substract 2 weeks and show that date in "DG LCC"?
6 weeks 1 day, where do you enter those values, please be more specific?
Copy link to clipboard
Copied
Un thé same field "DG LCC"
thank you
Copy link to clipboard
Copied
Weeks + days please
Copy link to clipboard
Copied
If you enter "7 SA" (like in your photo) actual date is 5 weeks +1day?
Copy link to clipboard
Copied
IF I enter "7 SA + 0 day" Date of conception "DG LCC" is befor 5 weeks + 0 day
if I enter "7 SA + 1 day" Date of conception "DG LCC" is befor 5 weeks + 1 day
if I enter "7 SA + 2 day" Date of conception "DG LCC" is befor 5 weeks 2 1 day
itc ...
thanks
Copy link to clipboard
Copied
sory for the last :
if I enter "7 SA + 2 day" Date of conception "DG LCC" is befor 5 weeks + 2 day
Copy link to clipboard
Copied
Try this:
var date = new Date();
if(event.value == "")
this.getField("DG LCC").value = "";
else {
var str = event.value;
var n = str.match(/\d/g);
var nw = n.join("");
var num = nw.slice(0, -1);
var numday = str.match(/(\d+)(?!.*\d)/g);
date.setDate(date.getDate() -(Number(num)*7-14+Number(numday)));
this.getField("DG LCC").value = util.printd("dd-mmm-yyyy", date);}
Copy link to clipboard
Copied
Thanks alot
you are genius.