tsql script

  • I want to print out the day as in numeric, but when i run this query I don't have any output for display. Can someone please help, I don't know what I am doing wrong

    DECLARE @myVariable AS NUMERIC

    SELECT @myVariable =

    DATEDIFF(DAY,GETDATE(),convert(datetime,[myColumn],0))) from mydatabase.dbo.mytable

    PRINT @myVariable

  • amadou.barry (4/16/2013)


    I want to print out the day as in numeric, but when i run this query I don't have any output for display. Can someone please help, I don't know what I am doing wrong

    DECLARE @myVariable AS NUMERIC

    SELECT @myVariable =

    DATEDIFF(DAY,GETDATE(),convert(datetime,[myColumn],0))) from mydatabase.dbo.mytable

    PRINT @myVariable

    What's the base datatype of myColumn in myTable?

    Also, are you not getting any output (as in no rows), or is the output Blank? or NULL for that matter?


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • the data type for mycolumn is varchar and I am expecting some numeric values as I have setup the mycolumn to output numeric values.

    I can get the output desired from running the script below

    SELECT DATEDIFF(DAY,GETDATE(),

    (CONVERT(DATETIME,[mycolumn],0))) from mydatabase.dbo.mytable

    thanks

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

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