Home Forums SQL Server 2008 T-SQL (SS2K8) Formatting date of birth using South African ID number RE: Formatting date of birth using South African ID number

  • 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[/url]

    @SeanPearceSQL

    About Me[/url]