Question Extracting part of a date

Sketchin

Registered User.
Local time
Today, 05:56
Joined
Dec 20, 2011
Messages
577
Hello,

I have a field called 'Dateout' with a field type 'date/time'.

How can I set the default value of a different field called 'dateprefix' to be the month of the date in the DateOut field?
I have tried Default Value '=Mid([Dateout],4,3) and '=Month([DateOut])' with no success.

Thanks for your help
 
If it's a date/time field you'd want the Month() function. The problem with using the default value property is that the DateOut value has to exist at the point the record is created, and presumably it does not. Presuming I was going to save the value at all, I'd probably set it in the after update event of the DateOut control.
 
Hi -

Try something like:

x = now()
? format(x, "mmm")
Feb

HTH - Bob
 
You say 'default' value, that implies this other field's value could be changed. Is that true? Could this other field have a value that doesn't equal the month value of the Dateout field?
 
Yes, that was very stupid of me to put this in the default value field! This value changes depending on dates entered into a form.

I will have to take a different approach.

Thanks for smartening me up!
 
If this field's value is dependent on another field, then you shouldn't store it. You should calculate it whenever you need to use it.

Take a person's age for example. If you know their birthdate, you don't store their age, you simply compare their birthday to the current date and determine their age whenever you need it. You don't have a field in a table called 'Age' because its dependent on a value you already do store.
 

Users who are viewing this thread

Back
Top Bottom