Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Time Calculation

Discussion in 'Information Technology' started by Jenn, Jul 28, 2006.

  1. Jenn

    Jenn
    Expand Collapse
    Guest

    I need to show the age of something that was entered in my database. Meaning,
    I need to have the difference between the time stamp when the record was
    entered and the current date. In terms of months. I need to have this show up
    with the records on my report as a field named "age". I have a column in my
    main table that has the timestamp for when the record was entered (its called
    "date found"). The problem is I do not know how to take that date and perform
    the calc from a current date. I am not even sure where to do this
    calculation... Any help would be greatly appreciated! TIA!
     
  2. Rick B

    Rick B
    Expand Collapse
    Guest

    Just add an unbound field in your reports or forms and put the following in
    it...

    =IIf([datefound],DateDiff("m",[datefound],Date())\12 & " yrs. " &
    (DateDiff("m",[datefound],Date()) Mod 12 & " mts."),"")


    That will show something like...

    2 yrs. 6 mts.


    Or you could use...


    =IIf([datefound],DateDiff("m",[datefound],Date())

    That would just give the months.



    You can also do this in a query by adding a new column and then putting
    something like....

    Age: IIf([datefound],DateDiff("m",[datefound],Date())


    But, you don't need to store this in your table.

    --
    Rick B



    "Jenn" <Jenn@discussions.microsoft.com> wrote in message
    news:740DB40F-EAAA-4CCD-83D9-6E8447128B01@microsoft.com...
    >I need to show the age of something that was entered in my database.
    >Meaning,
    > I need to have the difference between the time stamp when the record was
    > entered and the current date. In terms of months. I need to have this show
    > up
    > with the records on my report as a field named "age". I have a column in
    > my
    > main table that has the timestamp for when the record was entered (its
    > called
    > "date found"). The problem is I do not know how to take that date and
    > perform
    > the calc from a current date. I am not even sure where to do this
    > calculation... Any help would be greatly appreciated! TIA!
     
  3. Jenn

    Jenn
    Expand Collapse
    Guest

    One more thing, I need my report to sort from longest age to shortest (Show
    report in decreasing age) how would I do this? Thanks for everything else and
    the super quick response!

    "Rick B" wrote:

    > Just add an unbound field in your reports or forms and put the following in
    > it...
    >
    > =IIf([datefound],DateDiff("m",[datefound],Date())\12 & " yrs. " &
    > (DateDiff("m",[datefound],Date()) Mod 12 & " mts."),"")
    >
    >
    > That will show something like...
    >
    > 2 yrs. 6 mts.
    >
    >
    > Or you could use...
    >
    >
    > =IIf([datefound],DateDiff("m",[datefound],Date())
    >
    > That would just give the months.
    >
    >
    >
    > You can also do this in a query by adding a new column and then putting
    > something like....
    >
    > Age: IIf([datefound],DateDiff("m",[datefound],Date())
    >
    >
    > But, you don't need to store this in your table.
    >
    > --
    > Rick B
    >
    >
    >
    > "Jenn" <Jenn@discussions.microsoft.com> wrote in message
    > news:740DB40F-EAAA-4CCD-83D9-6E8447128B01@microsoft.com...
    > >I need to show the age of something that was entered in my database.
    > >Meaning,
    > > I need to have the difference between the time stamp when the record was
    > > entered and the current date. In terms of months. I need to have this show
    > > up
    > > with the records on my report as a field named "age". I have a column in
    > > my
    > > main table that has the timestamp for when the record was entered (its
    > > called
    > > "date found"). The problem is I do not know how to take that date and
    > > perform
    > > the calc from a current date. I am not even sure where to do this
    > > calculation... Any help would be greatly appreciated! TIA!

    >
    >
    >
     
  4. Rick B

    Rick B
    Expand Collapse
    Guest

    Just sort the report by your DATEFOUND field. The one with the oldest date
    is going to have the largest age.


    --
    Rick B



    "Jenn" <Jenn@discussions.microsoft.com> wrote in message
    news:9769378D-839B-4B44-9B69-20FB5C8C4201@microsoft.com...
    > One more thing, I need my report to sort from longest age to shortest
    > (Show
    > report in decreasing age) how would I do this? Thanks for everything else
    > and
    > the super quick response!
    >
    > "Rick B" wrote:
    >
    >> Just add an unbound field in your reports or forms and put the following
    >> in
    >> it...
    >>
    >> =IIf([datefound],DateDiff("m",[datefound],Date())\12 & " yrs. " &
    >> (DateDiff("m",[datefound],Date()) Mod 12 & " mts."),"")
    >>
    >>
    >> That will show something like...
    >>
    >> 2 yrs. 6 mts.
    >>
    >>
    >> Or you could use...
    >>
    >>
    >> =IIf([datefound],DateDiff("m",[datefound],Date())
    >>
    >> That would just give the months.
    >>
    >>
    >>
    >> You can also do this in a query by adding a new column and then putting
    >> something like....
    >>
    >> Age: IIf([datefound],DateDiff("m",[datefound],Date())
    >>
    >>
    >> But, you don't need to store this in your table.
    >>
    >> --
    >> Rick B
    >>
    >>
    >>
    >> "Jenn" <Jenn@discussions.microsoft.com> wrote in message
    >> news:740DB40F-EAAA-4CCD-83D9-6E8447128B01@microsoft.com...
    >> >I need to show the age of something that was entered in my database.
    >> >Meaning,
    >> > I need to have the difference between the time stamp when the record
    >> > was
    >> > entered and the current date. In terms of months. I need to have this
    >> > show
    >> > up
    >> > with the records on my report as a field named "age". I have a column
    >> > in
    >> > my
    >> > main table that has the timestamp for when the record was entered (its
    >> > called
    >> > "date found"). The problem is I do not know how to take that date and
    >> > perform
    >> > the calc from a current date. I am not even sure where to do this
    >> > calculation... Any help would be greatly appreciated! TIA!

    >>
    >>
    >>
     
  5. Jenn

    Jenn
    Expand Collapse
    Guest

    Works great! Thanks!!!!!!

    "Rick B" wrote:

    > Just sort the report by your DATEFOUND field. The one with the oldest date
    > is going to have the largest age.
    >
    >
    > --
    > Rick B
    >
    >
    >
    > "Jenn" <Jenn@discussions.microsoft.com> wrote in message
    > news:9769378D-839B-4B44-9B69-20FB5C8C4201@microsoft.com...
    > > One more thing, I need my report to sort from longest age to shortest
    > > (Show
    > > report in decreasing age) how would I do this? Thanks for everything else
    > > and
    > > the super quick response!
    > >
    > > "Rick B" wrote:
    > >
    > >> Just add an unbound field in your reports or forms and put the following
    > >> in
    > >> it...
    > >>
    > >> =IIf([datefound],DateDiff("m",[datefound],Date())\12 & " yrs. " &
    > >> (DateDiff("m",[datefound],Date()) Mod 12 & " mts."),"")
    > >>
    > >>
    > >> That will show something like...
    > >>
    > >> 2 yrs. 6 mts.
    > >>
    > >>
    > >> Or you could use...
    > >>
    > >>
    > >> =IIf([datefound],DateDiff("m",[datefound],Date())
    > >>
    > >> That would just give the months.
    > >>
    > >>
    > >>
    > >> You can also do this in a query by adding a new column and then putting
    > >> something like....
    > >>
    > >> Age: IIf([datefound],DateDiff("m",[datefound],Date())
    > >>
    > >>
    > >> But, you don't need to store this in your table.
    > >>
    > >> --
    > >> Rick B
    > >>
    > >>
    > >>
    > >> "Jenn" <Jenn@discussions.microsoft.com> wrote in message
    > >> news:740DB40F-EAAA-4CCD-83D9-6E8447128B01@microsoft.com...
    > >> >I need to show the age of something that was entered in my database.
    > >> >Meaning,
    > >> > I need to have the difference between the time stamp when the record
    > >> > was
    > >> > entered and the current date. In terms of months. I need to have this
    > >> > show
    > >> > up
    > >> > with the records on my report as a field named "age". I have a column
    > >> > in
    > >> > my
    > >> > main table that has the timestamp for when the record was entered (its
    > >> > called
    > >> > "date found"). The problem is I do not know how to take that date and
    > >> > perform
    > >> > the calc from a current date. I am not even sure where to do this
    > >> > calculation... Any help would be greatly appreciated! TIA!
    > >>
    > >>
    > >>

    >
    >
    >
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page