Archives of the TeradataForum
Message Posted: Fri, 02 Nov 2012 @ 22:20:58 GMT
Subj: | | Re: Subtraction between dates |
|
From: | | McCall, Glenn David |
I am surprised that your query "Select '2012-02-20' - '2012-02-10'" would produce anything but an error.
So I tried it, and was surprised that I didn't get an error. So I've learnt something. Hopefully I will return the favour.
To get what you want "Kindly let me know how can I get result as this many days difference." Try casting the strings to dates.
Select cast('2012-02-20' as date) - cast('2012-02-10' as date);
Result: 41
Also "Kindly let me know how can I get result as this many days difference." This should produce the result you are after:
Select cast('2012-02-20' as date) - 40
Result: 2012-01-11
Glenn Mc
|