Skip to main content
waelk38411626
Known Participant
Feb 22, 2022 8:23 PM UTC
Answered

calculating date of conception

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

 

This topic is closed to new replies. Start a new post to keep the conversation going.
Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
Feb 23, 2022 8:21 AM UTC

sory for the last :

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

 


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

11 replies

Nesa Nurani
Community Expert
Community Expert
Feb 23, 2022 6:10 AM UTC

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
waelk38411626
Known Participant
Feb 23, 2022 6:49 AM UTC

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
Nesa Nurani
Community Expert
Community Expert
Feb 23, 2022 7:19 AM UTC

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
waelk38411626
Known Participant
Feb 22, 2022 8:33 PM UTC

I wanted to add that the count from current date 

Translate