Need to find out whether date is of which data type

  • ScottPletcher (1/10/2013)


    dwain.c (1/9/2013)


    Steven - Those FUNCTIONs look like nice work. I've saved them off for future analysis. 🙂

    You might want to review the new functions in SQL 2012 dealing with conversion issues first. It might save you unneeded effort :-).

    Noted for future reference because, alas, at this time I must work only with the stone knives and bear skins available in SQL 2008.


    My mantra: No loops! No CURSORs! No RBAR! Hoo-uh![/I]

    My thought question: Have you ever been told that your query runs too fast?

    My advice:
    INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
    The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.

    Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
    Since random numbers are too important to be left to chance, let's generate some![/url]
    Learn to understand recursive CTEs by example.[/url]
    [url url=http://www.sqlservercentral.com/articles/St

  • declare

    @datetime datetimeoffset = '2012-10-25 00:00:00.000 +04:30'

    select

    case

    when (DATEPART(TZ, @datetime) <> 0 and DATEPART(TZ, @datetime) is not null OR CONVERT(TIME(0),@datetime) <> '00:00:00')

    then 0

    when (DATEPART(TZ, @datetime) = 0 and @datetime <> '')

    then 1

    when (DATEPART(TZ, @datetime) is null)

    then NULL

    end as Precision

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

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