UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Add Calculated Date To Table, Access 2010    
 
   
edin14166
post Nov 1 2018, 05:26 AM
Post#1



Posts: 364
Joined: 15-November 05
From: BiH


Hello,
I have a table and there is a date field called "DatumDo" now I would like to add another field to this table which is 15 days prior to the date which already exists,
I tried but without success?
How can I do this?
Go to the top of the page
 
JonSmith
post Nov 1 2018, 05:41 AM
Post#2



Posts: 3,957
Joined: 19-October 10



Don't, just calculate it in a query when you want to. Calculated values stored rarely be stored as a table field.
Go to the top of the page
 
edin14166
post Nov 1 2018, 05:53 AM
Post#3



Posts: 364
Joined: 15-November 05
From: BiH


this time I need it in table field
Go to the top of the page
 
JonSmith
post Nov 1 2018, 05:54 AM
Post#4



Posts: 3,957
Joined: 19-October 10



I doubt that, why do you think you need to store it?

JS
Go to the top of the page
 
edin14166
post Nov 1 2018, 05:59 AM
Post#5



Posts: 364
Joined: 15-November 05
From: BiH


because I am doing some calculations based on this table only..
I am trying to use function
=DateAdd("d", -15, [DatumDo])

I get syntax error ...
This post has been edited by edin14166: Nov 1 2018, 06:02 AM
Go to the top of the page
 
BruceM
post Nov 1 2018, 06:50 AM
Post#6


UtterAccess VIP
Posts: 7,724
Joined: 24-May 10
From: Downeast Maine


Try a test:

=DateAdd("d", -15, Date())

If that works, is DatumDo a date/time field?

I agree with Jon that there is no need to store the calculation result, assuming the DatumDo field is in the same table. I have noticed that people more familiar with spreadsheets are OK with having a Sum or other calculation, and testing against that calculated value. I have not known them to insist on doing Paste Special >> Values with that result before using it in other calculations. However, that way of thinking is often not carried into Access.

As for the syntax error, without context it is difficult to know why it is occurring, assuming DatumDo is a date/time field that is spelled correctly. Also, it would be necessary to know how you are using the expression.
Go to the top of the page
 
edin14166
post Nov 1 2018, 06:54 AM
Post#7



Posts: 364
Joined: 15-November 05
From: BiH


Bruce,
Thank You I just used query calculation...
Go to the top of the page
 
JonSmith
post Nov 1 2018, 06:56 AM
Post#8



Posts: 3,957
Joined: 19-October 10



Great! Using a query is a more appropriate way to get this information vs storing calculated values!
Go to the top of the page
 
BruceM
post Nov 1 2018, 08:58 AM
Post#9


UtterAccess VIP
Posts: 7,724
Joined: 24-May 10
From: Downeast Maine


To use the expression in a query field, at the top of a new column in query design view, using a query that includes the DatumDo field (a date/time field, right?) something like:

DateCalc: DateAdd("d", -15, [DatumDo])

If that doesn't work, I suggested a way to test, asked some questions that need answers, and suggested using the table name rather than extracting the Record Source property from the subform.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    20th November 2018 - 01:23 PM