|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
calculating a date difference...Hi all...
Is there a function to calculate the number of months between 2 different dates?? Example: @varNumberOfMonths = DATEDIFF(month,'08/01/05','07/01,05' ) Thanks in advance for any help... You have a misplaced comma. Try this:
DATEDIFF(month,'08/01/05','07/01/05' ) Show quote "certolnut" <whitney_n***@hotmail.com> wrote in message news:e6CKawaqFHA.528@TK2MSFTNGP09.phx.gbl... > Hi all... > > Is there a function to calculate the number of months between 2 different > dates?? > > Example: @varNumberOfMonths = DATEDIFF(month,'08/01/05','07/01,05' ) > > Thanks in advance for any help... > Did you try it?
DECLARE @NumberOfMonths SMALLINT -- we know it's a VAR because @, no var prefix necessary SET @NumberOfMonths = DATEDIFF(MONTH, '20050701', '20050801') -- do not use mm/dd/yy format PRINT @NumberOfMonths Show quote "certolnut" <whitney_n***@hotmail.com> wrote in message news:e6CKawaqFHA.528@TK2MSFTNGP09.phx.gbl... > Hi all... > > Is there a function to calculate the number of months between 2 different > dates?? > > Example: @varNumberOfMonths = DATEDIFF(month,'08/01/05','07/01,05' ) > > Thanks in advance for any help... > Thats got it, actually I had no idea that I was that close....lucky guess
(but not lucky enough) Thanks so much for your help!! Show quote "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message news:Oggdd5aqFHA.3352@TK2MSFTNGP14.phx.gbl... > Did you try it? > > > DECLARE @NumberOfMonths SMALLINT > -- we know it's a VAR because @, no var prefix necessary > > SET @NumberOfMonths = DATEDIFF(MONTH, '20050701', '20050801') > -- do not use mm/dd/yy format > > PRINT @NumberOfMonths > > > > "certolnut" <whitney_n***@hotmail.com> wrote in message > news:e6CKawaqFHA.528@TK2MSFTNGP09.phx.gbl... >> Hi all... >> >> Is there a function to calculate the number of months between 2 different >> dates?? >> >> Example: @varNumberOfMonths = DATEDIFF(month,'08/01/05','07/01,05' ) >> >> Thanks in advance for any help... >> > > > Thats got it, actually I had no idea that I was that close....lucky guess Hmmm, have you considered downloading the documentation? Guessing kind of > (but not lucky enough) slows development down. http://www.aspfaq.com/2229 No offense meant, and I appreciate the help, but I defy anyone to get
anything other than the most rudimentary of help from that documentation... Show quote "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message news:uFK0iCbqFHA.2072@TK2MSFTNGP14.phx.gbl... >> Thats got it, actually I had no idea that I was that close....lucky guess >> (but not lucky enough) > > Hmmm, have you considered downloading the documentation? Guessing kind of > slows development down. > > http://www.aspfaq.com/2229 > > No offense meant, and I appreciate the help, but I defy anyone to get I disagree completely; this is the place to get help for SQL Server. Are > anything other than the most rudimentary of help from that > documentation... you trying to tell me that the following article would not have helped you in any way? http://msdn.microsoft.com/library/en-us/tsqlref/ts_da-db_5vxi.asp Certainly it does, no question, your right. But this documentation has
failed me in the past, so I felt the need to turn to other resources instead of wasting time. I'm sorry if you felt this was a waste of yours.... Show quote "Aaron Bertrand [SQL Server MVP]" <ten.xoc@dnartreb.noraa> wrote in message news:umFnHebqFHA.2596@TK2MSFTNGP09.phx.gbl... >> No offense meant, and I appreciate the help, but I defy anyone to get >> anything other than the most rudimentary of help from that >> documentation... > > I disagree completely; this is the place to get help for SQL Server. Are > you trying to tell me that the following article would not have helped you > in any way? > > http://msdn.microsoft.com/library/en-us/tsqlref/ts_da-db_5vxi.asp > |
|||||||||||||||||||||||