select part of a field

R

Rodolfo Fontes

Hi group,

I have a field called CodOperation, and it's my control of user's
actions
It's like CODE USER + DATE ( YY, MM, DD ) + HOUR ( HH + MM + SS ).
The trouble is, i wanna get just the date of this field, and set it from
a form.
How can i do that on a query? and if possible, already make it appear
like dd/mm/yy.

CodOperation
050040720154117

Example: 050 + 040720 + 154117

Thanks,
Rodolfo Fontes
 
A

Allen Browne

If the field is always the same number of digits, try:
DateSerial(Mid([CodOperation], 4,2), Mid([CodOperation], 6,2),
Mid([CodOperation], 8,2))

This generates a true date field. It should display in the format you
specified for Short Date in the Windows Control Panel | Regional Options.
 
R

Rodolfo Fontes

Thanks Allen for helping

My version of the Access is 2000, portuguese - Brazil.
So the sintax changes a bit, like
data: DataSerial(Meio([T NF_E].[Cod_NF_E];4,2);Meio([T
NF_E].[Cod_NF_E];6,2);Meio([T NF_E].[Cod_NF_E];8,2))
The trouble now is that it returns just "Error" on the query, without any
warnings.

Any Idea?

Rodolfo Fontes

Allen Browne said:
If the field is always the same number of digits, try:
DateSerial(Mid([CodOperation], 4,2), Mid([CodOperation], 6,2),
Mid([CodOperation], 8,2))

This generates a true date field. It should display in the format you
specified for Short Date in the Windows Control Panel | Regional Options.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rodolfo Fontes said:
Hi group,

I have a field called CodOperation, and it's my control of user's
actions
It's like CODE USER + DATE ( YY, MM, DD ) + HOUR ( HH + MM + SS ).
The trouble is, i wanna get just the date of this field, and set it
from
a form.
How can i do that on a query? and if possible, already make it appear
like dd/mm/yy.

CodOperation
050040720154117

Example: 050 + 040720 + 154117

Thanks,
Rodolfo Fontes
 
A

Allen Browne

Open the Immediate Window (press Ctrl+G).

Try out your example there using a literal value like 050040720154117, and
when you get the desired results you can build the same thing in the query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rodolfo Fontes said:
Thanks Allen for helping

My version of the Access is 2000, portuguese - Brazil.
So the sintax changes a bit, like
data: DataSerial(Meio([T NF_E].[Cod_NF_E];4,2);Meio([T
NF_E].[Cod_NF_E];6,2);Meio([T NF_E].[Cod_NF_E];8,2))
The trouble now is that it returns just "Error" on the query, without any
warnings.

Any Idea?

Rodolfo Fontes

Allen Browne said:
If the field is always the same number of digits, try:
DateSerial(Mid([CodOperation], 4,2), Mid([CodOperation], 6,2),
Mid([CodOperation], 8,2))

This generates a true date field. It should display in the format you
specified for Short Date in the Windows Control Panel | Regional Options.


Rodolfo Fontes said:
Hi group,

I have a field called CodOperation, and it's my control of user's
actions
It's like CODE USER + DATE ( YY, MM, DD ) + HOUR ( HH + MM + SS ).
The trouble is, i wanna get just the date of this field, and set it
from
a form.
How can i do that on a query? and if possible, already make it
appear
like dd/mm/yy.

CodOperation
050040720154117

Example: 050 + 040720 + 154117

Thanks,
Rodolfo Fontes
 
V

Van T. Dinh

It looks to me that you use both comma and semicolon as argument separator.
Usually, it is one or the other, not both. If semicolon is you argument
separator, try:

DataSerial(Meio([T NF_E].[Cod_NF_E]; 4; 2);
Meio([T NF_E].[Cod_NF_E]; 6; 2);
Meio([T NF_E].[Cod_NF_E]; 8; 2))

(type as *one* line in your query).

HTH
Van T. Dinh
MVP (Access)
 
Top