Splitting a date into days, months and years

Last updated:

    Overview

    This section demonstrates how to split a date into days, months and years.

    Splitting a date into days, months and years

    Certain forms may have the day, month and year split into different fields:

    File:test/insolvency/230_21+PDF+templates/090_Additional+Steps/050_Splitting+a+date+into+days%2C+months+and+years/PDF_SplitDate.png

    The listing below takes the current date and splits it up accordingly:

    INSERT INTO @Data
    SELECT 'Today_Day', CAST(datepart(DD, GETDATE()) AS nVarChar(MAX))
    
    INSERT INTO @Data
    SELECT 'Today_Month', CAST(datepart(MM, GETDATE()) AS nVarChar(MAX))
    
    INSERT INTO @Data
    SELECT 'Today_Year', CAST(datepart(YYYY, GETDATE()) AS nVarChar(MAX))