Re: Number of months...
Posted in 1997
Michael, I have some 4GL programs in which I had to find the number of months between 2 datetimes. All I did was set a variable to interval month(5) to month. the I do a let statement substracting the 2 datetimes. To make it work properly I had todo an extend function setting the datetimes to year to month but this can all be done in one line of code. It can also be done with date datatypes also. You didn't say what type of language you were using or if you were trying this with SQL or not. It can be done with a SQL statement but I don't remember the syntax right off hand. Hope this helps. --- ,-, |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ======= ___|| | | ----- //_ || | CANNON EXPRESS | ---- ,-----'| ~ | | | -- |o-----|__ |--`======_______________________________======___| ~~~~~~~~ `-(*)--===~~~~~~(*)(*)| (*)(*)| ------- ------------------------------------------------------------------------- Joseph Cullipher |E-mail: joseph@cannonexpress.com PO Box 364 |opinions express are those of my own and Springdale, AR 72764 USA |don't necessarily reflect those of my company ------------------------------------------------------------------------- On 31 Mar 1997, Michael Hoffman wrote: > > Ok, this may be the simplest question I've ever posted, but, then agin, it may > be as tough as we've found. > > What we have are 2 dates and 2 datetimes. We need to find the number of months > between each of the dates and each of the datetimes. Since there is no defined > "MONTH" function, we have had to come up with our own. They seem extremely > cludgy and inefficient. > > I am hoping the gurus out there will have come across this in the past and can > shed some light. > > I would post our code, but it's almost embarrassing! :-} We went so far as > to parse the date string. As I said, it is ugly code. > > Thanks fort the help! > > Michael Hoffman >