Time Data Format

  • Hello All and Good Day

    I am looking for a way to store the current TimeofDay in a table, but not include the default Date of 1/1/1900. Example: 1/1/1900 2:35:00 PM - I want only the Time, not the Date. The field is holding "smalldatetime"

    Is there a way to truncate or cast the date portition from this data for storing in a table. Perhaps a Trigger or something like that when the data is inserted into the table, etc......

    I am open to any and all suggestions.

    Thanks in advance for your assistnace

    Have a nice day.

    Andrew

    How long a minute is....

    Depends on what side of the bathroom door you are on.


    How long a minute is....
    Depends on what side of the bathroom door you are on.

  • Ok first of in a datetime field even a shortdatetime you technically have a date that is not visible. If you attach Excel to a table and key the time only you will see the value by querying the table in QA. In Excel you will see only the time. In QA you will see 12-31-1899 and the time (Sorry not in front of me could be 12-30, there was some screwy date on some system I work with where 30 was the day but may have been Oracle). Anyway you then have a few options. But based on what you get you should be able to subtract 1 day or 2 and depending on the application reading it should read as time only (like Excel). If this is a custom app or does not work that way you can use CONVERT(VARCHAR,SDTCOLNAME,108) to have the output formated as hh:mm:ss (see SQL BOL for more detail).

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply