cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
George_Serg
Frequent Visitor

Calculate Birth Date from a different field

My situation is as follows.. In CDS I have created a field in my costumers entity for their social security number which consists of 11 characters. the first six characters of this number (which keep in mind is stored as text data type not as number)  represent the birth date of the costumer. For example someone with the ssn 05118767654 is born in 05 of November 1987 (051187). I also have a birth date field stored as only date data type. My question is:  If I enter the social security number in a form, Is there anyway at all that the date field can be automatically calculated automatically by the first 6 characters of the ssn??

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @George_Serg ,

Put this on a label and see if you get the correct date

With(
   {
      wDay: Left(
         TxtSSN.Text,
         2
      ),
      wMonth: Mid(
         TxtSSN.Text,
         3,
         2
      ),
      wYear: Mid(
         TxtSSN.Text,
         5,
         2
      )
   },
   DateValue(
      wMonth & "/" & wDay & "/" & If(
         Value(wYear) < 20,
         "20",
         "19"
      ) & wYear
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

4 REPLIES 4
PowerRanger
Resolver II
Resolver II

@George_Serg 

 

try this formular

 

 

Text(Right(Left(txtSSN.Text,4),2) & "." & Left(txtSSN.Text,2) & "." & Right(Left(txtSSN.Text,8),4),"[$-en]dd/MM/yyyy")

 

If you place a datepicker on your screen ad take this formular as the Default value the control should show the date you enter via the ssn number

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

gabibalaban
Super User
Super User

Hi @George_Serg ,

 

If you think to be a calculated field in CDS, I'm affraid that all you can obtain is a text field looking like this:

gabibalaban_0-1603470615265.png

You can set this in calculated field, calculation:

gabibalaban_1-1603470762969.png

and the formula looks like this:

Concat(TrimRight(cr405_ssn, 9), ".", TrimLeft(TrimRight(cr405_ssn, 7), 2), ".", TrimLeft(TrimRight(cr405_ssn, 5), 4))

 where cr405_ssn is your SSN field.

 

Hope it helps !

Hi @George_Serg ,

Put this on a label and see if you get the correct date

With(
   {
      wDay: Left(
         TxtSSN.Text,
         2
      ),
      wMonth: Mid(
         TxtSSN.Text,
         3,
         2
      ),
      wYear: Mid(
         TxtSSN.Text,
         5,
         2
      )
   },
   DateValue(
      wMonth & "/" & wDay & "/" & If(
         Value(wYear) < 20,
         "20",
         "19"
      ) & wYear
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

@WarrenBelzThank you, this is exactly what I was looking for.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,799)