DateTime as an Integer any advantages

  • Is there any advantage to representing a datetime column as an integer i.e. for speed ect? The field will have date values in it -- YMDH.

  • From the analyst's side I hate it when they store data like that. You lose all of the functionality for doing comparisons without doing math against the column. It also allows for non dates to get into the data like 99999999 and 00000000.


  • Also - datetimes are already numeric (albeit float/double). I'd say the deficits outweigh any benefits (nothing like having to cast it to varchar first, then to datetime), just to display it on, say, a report.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • one of the top 3 rules for any rdbms: use the correct datatype !

    If you know it concerns a date / time / datetime column, use the datetime datatype !

    Your rdbms provides methodes for it, knows how to handle it and, because of the datatype, also validates it !

    Storing it as integer would only provide a risk for abuse !

    Datediff, dateadd, datepart, ... will help you.

    btw if imported e.g. to a vb.net dataset/datatable, your grid will also know the datatype and format it according to the client's preferences, unless you tell it to format otherwise.

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

Viewing 4 posts - 1 through 3 (of 3 total)

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