April 16, 2013 at 3:43 pm
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
SELECT @myVariable =
DATEDIFF(DAY,GETDATE(),convert(datetime,[myColumn],0))) from mydatabase.dbo.mytable
PRINT @myVariable
April 16, 2013 at 3:59 pm
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 wrongDECLARE @myVariable AS NUMERICSELECT @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?
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
April 16, 2013 at 4:08 pm
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
(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