DateTime Trick

  • Let me be clear, my comments about the usefulness of convert are in the context of doing an import data task, or a one-off query to go to another system. For example, I occasionally pull data that feeds some SAS code for one of our statistics gurus. He asks me to convert dates to YYYYMMDD.

    Now, I am absolutely sure that I waste a few cycles doing this with a CONVERT() in my query. But the system is under no CPU stress, and the alternative is to either refuse his request, requiring him to figure out how to handle native data formats on his side and go through all his code making changes... or to learn enough SAS to do it myself. That is a waste of valuable man hours to keep an insignificant load off the CPU. Those man-hours could be better spent on projects that would REALLY make a difference to performance, or to my company's revenue. In this case, common sense dictates that I sacrifice a little machine resource to save a lot of people resource.

    Machines are still meant to serve man.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Bob - at the end of the article there is a link to another post containing some "pros" for using CONFERT(), etc...

  • My apologies for not reading it in the entirety. I will go back and do that now. Thanks. 🙂

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Both articles make good points, but note that I did say with some reporting applications. For instance it would be wasted time with a Crystal report.

    I think that the original blog picked an example that doesn't really line up with the conversation that we're having, but his opinion is valid never the less, except the part about the T-SQL example being more difficult to read than C# or VB. That would definitely be an 'in the eye of the beholder' opinion.

    As for performance. That is always a consideration, but tweaking it to the max can be a luxury item with some jobs. For instance with a medium sized company needing a custom report from an over-powered, under-utilized database server. I don't work with Enterprise level projects every day, but my time still counts, and ultimately giving the client the most bang for his buck is what we are measured by.

    Tom Garth
    Vertical Solutions[/url]

    "There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers
  • There's been a lot of interesting discussion here, but now I'm curious what Volkan, the author of this QOD, had in mind. Was it to show that CONVERT could isolate the time portion of a datetime? The explanation given would imply that. Or was the use of mixed delimiters the "trick" to which the title referred?

Viewing 5 posts - 16 through 19 (of 19 total)

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