SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Formatting date of birth using South African ID number


Formatting date of birth using South African ID number

Author
Message
Feeg
Feeg
SSC Veteran
SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)

Group: General Forum Members
Points: 288 Visits: 2004
lol too many Hehe
I think the OP should maybe shed some more light to get rid of these assumptions
Using the DOB to verify the century is an option

MCITP: Database Administrator 2005
MCTS DBA 2008
cyagasa
cyagasa
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 35
substring is working well


select
,left([IDNumber],2) as year
,SUBSTRING(Idnumber,3,2) as Month
,SUBSTRING (Idnumber,5,2) as day
,SUBSTRING(Idnumber ,7,4) as gender
,substring (idnumber ,10,3) nationality
from table


kind regards

Michael Gasa
Sean Pearce
Sean Pearce
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1830 Visits: 3432
cyagasa (10/9/2015)
substring is working well


select
,left([IDNumber],2) as year
,SUBSTRING(Idnumber,3,2) as Month
,SUBSTRING (Idnumber,5,2) as day
,SUBSTRING(Idnumber ,7,4) as gender
,substring (idnumber ,10,3) nationality
from table


kind regards

Michael Gasa

Substring works but can't guarantee the correct date.

ID Number: 1410095511000

Birth Date 2014/10/09
-- OR --
Birth Date 1914/10/09



The SQL Guy @ blogspot

@SeanPearceSQL

About Me
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search