DateDiff

  • Thread starter Thread starter les
  • Start date Start date
L

les

Here is my formula:
CAST(EVAL_DT - CAST('07/01/' + LEFT (POLEFFDT, 4) AS datetime) AS float) /
(365 / 12)

It is giving me the developments months in a year.
The problem is it is not giving me the answers in whole numbers.
When I use :
ROUND(CAST(EVAL_DT - CAST('07/01/' + LEFT (POLEFFDT, 4) AS datetime) AS
float) / (365 / 12), 0)
It rounds up which I do not want it to do.
Can someone show me where the Datediff should go in my formula?
Thanks!
 
Les

I thought "CAST" was a SQL-Server function, not an Access function. Where
are you trying to do this?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
In SQL.
I posted this here because past post for similar functions were listed here.
Just trying to post it where someone will look at it.
 
In MS SQL Server,

DATEDIFF(YEAR, someDateInThePast, GETDATE( ))

returns the number of year boundaries between the date in the past, and now.

DATEFIDD(WEEK, someDateInThePast, GETDATE( ))

returns the number of week boundaries.


To round down, you can use

FLOOR( expression )


which returns, in fact, the greatest integer smaller or equal to the
numerical expression value.


Vanderghast, Access MVP
 
In SQL.
I posted this here because past post for similar functions were listed here.
Just trying to post it where someone will look at it.

We'll look at it, but it would help a lot if you would explain the context and
your programming environment. This is a bit like walking into a bakery and
ordering a chocolate malt.
 
les said:
Here is my formula:
CAST(EVAL_DT - CAST('07/01/' + LEFT (POLEFFDT, 4) AS datetime) AS
float) / (365 / 12)

It is giving me the developments months in a year.
The problem is it is not giving me the answers in whole numbers.
When I use :
ROUND(CAST(EVAL_DT - CAST('07/01/' + LEFT (POLEFFDT, 4) AS datetime)
AS float) / (365 / 12), 0)
It rounds up which I do not want it to do.
Can someone show me where the Datediff should go in my formula?
Thanks!

This would have been more appropriately posted to sqlserver.programming,
but:

DATEDIFF(m,LEFT(POLEFFDT, 4) + '0701',EVAL_DT)
 
Back
Top