Combing Two Fields

M

Montana Rain

I have two fields in a database that I am trying to combine into 1.
The firs is a date fiel that I am only interested in the year. The
second is a number that is formated as "000". When I try to combine
them with a hyphen such as [year]&"-"&[number], I get the original
full date format and the original number format. Any way to get around
this. My goal is something like this: 2009-021

Thanks
 
J

John W. Vinson

I have two fields in a database that I am trying to combine into 1.
The firs is a date fiel that I am only interested in the year. The
second is a number that is formated as "000". When I try to combine
them with a hyphen such as [year]&"-"&[number], I get the original
full date format and the original number format. Any way to get around
this. My goal is something like this: 2009-021

Thanks

A date field is - must be - a full complete date. It can't be just a year,
even if the year is the only piece that interests you! If you just want to
store the year, use a Number (integer or long integer) field.

To combine them in a Query or in the control source of a textbox for display,
if you keep the date field, use

Year([datefield]) & "-" & Format([numberfield], "000")

You need the explicit Format statement because the number is stored as a pure
number - the Format property only affects how it's displayed in the datasheet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top