Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

calculating date of conception

Community Beginner ,
Feb 22, 2022 Feb 22, 2022

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

 

Capture d’écran 2022-02-22 à 21.19.00.png

TOPICS
Acrobat SDK and JavaScript , Mac
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Feb 22, 2022 Feb 22, 2022

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);}

 

Translate
Community Expert , Feb 23, 2022 Feb 23, 2022

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);}

Translate
Community Beginner ,
Feb 22, 2022 Feb 22, 2022

I wanted to add that the count from current date 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 22, 2022 Feb 22, 2022

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);}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 22, 2022 Feb 22, 2022

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 22, 2022 Feb 22, 2022

Substract 2 weeks and show that date in "DG LCC"?

6 weeks 1 day, where do you enter those values, please be more specific?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 22, 2022 Feb 22, 2022

Un thé same field "DG LCC"

thank you 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 22, 2022 Feb 22, 2022

Weeks + days please 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 22, 2022 Feb 22, 2022

If you enter "7 SA" (like in your photo) actual date is 5 weeks +1day?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 22, 2022 Feb 22, 2022

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 22, 2022 Feb 22, 2022

sory for the last :

if I enter "7 SA +  2 day" Date of conception "DG LCC" is befor 5 weeks + 2 day

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2022 Feb 23, 2022

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);}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 23, 2022 Feb 23, 2022
LATEST

Thanks alot 

you are genius.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines