Question Extracting part of a date (1 Viewer)

Sketchin

Registered User.
Local time
Yesterday, 19:14
Joined
Dec 20, 2011
Messages
575
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
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 19:14
Joined
Aug 30, 2003
Messages
36,133
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.
 

raskew

AWF VIP
Local time
Yesterday, 21:14
Joined
Jun 2, 2001
Messages
2,734
Hi -

Try something like:

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

HTH - Bob
 

plog

Banishment Pending
Local time
Yesterday, 21:14
Joined
May 11, 2011
Messages
11,669
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?
 

Sketchin

Registered User.
Local time
Yesterday, 19:14
Joined
Dec 20, 2011
Messages
575
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!
 

plog

Banishment Pending
Local time
Yesterday, 21:14
Joined
May 11, 2011
Messages
11,669
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

Top Bottom