Skip to main content
waelk38411626
Known Participant
February 22, 2022
Answered

calculating date of conception

  • February 22, 2022
  • 2 replies
  • 1977 views

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 has been closed for replies.
Correct answer Nesa Nurani

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

2 replies

Nesa Nurani
Community Expert
February 23, 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);}

 

waelk38411626
Known Participant
February 23, 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

Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
February 23, 2022

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

waelk38411626
Known Participant
February 22, 2022

I wanted to add that the count from current date