# Getting Only the Date Part of a Date/Time Stamp in SQL Server

**URL:** <https://forums.thehomestack.io/t/getting-only-the-date-part-of-a-date-time-stamp-in-sql-server/365>\
**Category:** Databases\
**Created:** [January 5, 2010, 3:51am UTC](https://forums.thehomestack.io/t/getting-only-the-date-part-of-a-date-time-stamp-in-sql-server/365 "2010-01-05T03:51:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://forums.thehomestack.io/uploads/default/original/1X/161426793bc0d8bdf0d1a6692b3e44446861cc72.jpeg) [@system](https://forums.thehomestack.io/u/system)\
**Post date:** [January 5, 2010, 3:51am UTC](https://forums.thehomestack.io/t/getting-only-the-date-part-of-a-date-time-stamp-in-sql-server/365/1 "2010-01-05T03:51:35Z")

</div>

To get the base back from the datetime in SQL:

```auto

    SELECT
    -- Get the full date/time stamp as a base.
    (
    GETDATE()
    ) AS date_time_part,
     
    -- Trying casting to a string then back to a date.
    (
    CAST(
    (
    STR( YEAR( GETDATE() ) ) + '/' +
    STR( MONTH( GETDATE() ) ) + '/' +
    STR( DAY( GETDATE() ) )
    )
    AS DATETIME
    )
    ) AS date_only_part,
     
    -- Try casting to float, rounding, and back to date.
    (
    CAST(
    FLOOR( CAST( GETDATE() AS FLOAT ) )
    AS DATETIME
    )
    ) AS date_only_part2,
     
    -- Try casting just to float to see what it looks like.
    (
    CAST( GETDATE() AS FLOAT )
    ) AS float_value,
     
    -- Try flooring to see the intermediary step.
    (
    FLOOR( CAST( GETDATE() AS FLOAT ) )
    ) AS int_value

```
