Date Function

L

lmossolle

I have a report that pulls the date from a table using a short date. I would
like to see only month and year. Can someone help?
 
R

Rick Brandt

lmossolle said:
I have a report that pulls the date from a table using a short date.
I would like to see only month and year. Can someone help?

Set the format property for the TextBox on the report to "mmm-yy" (or
similar).
 
A

Altair1972m

I have a very similar question and I am having a problem with Access.

There are fields for a mail merge for a table imported into access, so I
thought I'd attach the date information within

Field 1: Todaysdate
Field 2: Datein5Months
Field 3: MonthofDatein5Months
Field 4: YearofDatein5Months

Field 1:Date()
Field 2:DateAdd(“mâ€, 5, Date())
Field 3:DatePart(“mâ€, DateAdd(“mâ€,5, Date())
Field 4:DatePart(“mâ€, DateAdd(“mâ€,5, Date())

Field 1 works fine
Field 2 works fine
Field 3 produced Decemnber. I then checked the full date and found 12/31/1899
Field 4 produced 1905 I then checked the full date and found 1/7/1900

Why is Access doing this to me?

I tried drawing the information from Fields 1 and 2 for
MonthofDatein5Months: DatePart("m",[<nameoftable>]![TodaysDate])
That returned a blank column
I then tried the idea in response to this posting I am responding to and
that returned the same answers.

Help
 
L

Larry Linson

I can't reproduce your results, even after correcting the spacing in your
posted calculations. As they did not work when copied and pasted into the
Immediate Window, it would seem that you did not copy and paste them from
the database to the newsgroup article. The "interval" for DatePart to
extract the year is "Y", not "M".

All worked just fine for me, so there must be more detail you need to give
us if we are to be able to assist you.

Larry Linson
Microsoft Access MVP


Altair1972m said:
I have a very similar question and I am having a problem with Access.

There are fields for a mail merge for a table imported into access, so I
thought I'd attach the date information within

Field 1: Todaysdate
Field 2: Datein5Months
Field 3: MonthofDatein5Months
Field 4: YearofDatein5Months

Field 1:Date()
Field 2:DateAdd("m", 5, Date())
Field 3:DatePart("m", DateAdd("m",5, Date())
Field 4:DatePart("m", DateAdd("m",5, Date())

Field 1 works fine
Field 2 works fine
Field 3 produced Decemnber. I then checked the full date and found
12/31/1899
Field 4 produced 1905 I then checked the full date and found 1/7/1900

Why is Access doing this to me?

I tried drawing the information from Fields 1 and 2 for
MonthofDatein5Months: DatePart("m",[<nameoftable>]![TodaysDate])
That returned a blank column
I then tried the idea in response to this posting I am responding to and
that returned the same answers.

Help




Rick Brandt said:
Set the format property for the TextBox on the report to "mmm-yy" (or
similar).
 
A

Altair1972m

Damn tycophragical errors :)

To quote Daffy Duck: Letth thry that agahin. :(|)


Field 4:DatePart(“yyyyâ€, DateAdd(“mâ€,5, Date()) was what I meant to say was
the formula I used.

More information about the file.

The initial file of text is imported using import specs to a table for our
55 Months list. The month that is key is the 60th month. The disposition
needs to be returned by then.

The database form is designed to take the data from the 55 month table which
will appear on the disposition, write that data to a new table for the
disposition merge, run some code that someone else from your message board
posted to help me so that I can automatically calculate the internal control
number for each county, and write update that table with the new information.

I figured I could save time if that table also added the date fields of
Month and Year.

Altair1972m said:
I have a very similar question and I am having a problem with Access.

There are fields for a mail merge for a table imported into access, so I
thought I'd attach the date information within

Field 1: Todaysdate
Field 2: Datein5Months
Field 3: MonthofDatein5Months
Field 4: YearofDatein5Months

Field 1:Date()
Field 2:DateAdd(“mâ€, 5, Date())
Field 3:DatePart(“mâ€, DateAdd(“mâ€,5, Date())
Field 4:DatePart(“mâ€, DateAdd(“mâ€,5, Date())

Field 1 works fine
Field 2 works fine
Field 3 produced Decemnber. I then checked the full date and found 12/31/1899
Field 4 produced 1905 I then checked the full date and found 1/7/1900

Why is Access doing this to me?

I tried drawing the information from Fields 1 and 2 for
MonthofDatein5Months: DatePart("m",[<nameoftable>]![TodaysDate])
That returned a blank column
I then tried the idea in response to this posting I am responding to and
that returned the same answers.

Help




Rick Brandt said:
Set the format property for the TextBox on the report to "mmm-yy" (or
similar).
 
A

Altair1972m

Quoting Daffy Again: Leth try it from the othher end.

Did I use the proper terminology when I wrote
Field 4:DatePart(“mâ€, DateAdd(“mâ€,5, Date())
because the result is ending up as December

August 25, 2006 + 5 months Sept25 Oct25 Nov25 Dec25 Jan25



Altair1972m said:
Damn tycophragical errors :)

To quote Daffy Duck: Letth thry that agahin. :(|)


Field 4:DatePart(“yyyyâ€, DateAdd(“mâ€,5, Date()) was what I meant to say was
the formula I used.

More information about the file.

The initial file of text is imported using import specs to a table for our
55 Months list. The month that is key is the 60th month. The disposition
needs to be returned by then.

The database form is designed to take the data from the 55 month table which
will appear on the disposition, write that data to a new table for the
disposition merge, run some code that someone else from your message board
posted to help me so that I can automatically calculate the internal control
number for each county, and write update that table with the new information.

I figured I could save time if that table also added the date fields of
Month and Year.

Altair1972m said:
I have a very similar question and I am having a problem with Access.

There are fields for a mail merge for a table imported into access, so I
thought I'd attach the date information within

Field 1: Todaysdate
Field 2: Datein5Months
Field 3: MonthofDatein5Months
Field 4: YearofDatein5Months

Field 1:Date()
Field 2:DateAdd(“mâ€, 5, Date())
Field 3:DatePart(“mâ€, DateAdd(“mâ€,5, Date())
Field 4:DatePart(“mâ€, DateAdd(“mâ€,5, Date())

Field 1 works fine
Field 2 works fine
Field 3 produced Decemnber. I then checked the full date and found 12/31/1899
Field 4 produced 1905 I then checked the full date and found 1/7/1900

Why is Access doing this to me?

I tried drawing the information from Fields 1 and 2 for
MonthofDatein5Months: DatePart("m",[<nameoftable>]![TodaysDate])
That returned a blank column
I then tried the idea in response to this posting I am responding to and
that returned the same answers.

Help




Rick Brandt said:
lmossolle wrote:
I have a report that pulls the date from a table using a short date.
I would like to see only month and year. Can someone help?

Set the format property for the TextBox on the report to "mmm-yy" (or
similar).
 
L

Larry Linson

Altair1972m said:
Quoting Daffy Again: Leth try it from the othher end.

Did I use the proper terminology when I wrote
Field 4:DatePart("m", DateAdd("m",5, Date())
because the result is ending up as December

August 25, 2006 + 5 months Sept25 Oct25 Nov25 Dec25 Jan25

I should have coded those in a module to test, so I could just go back and
copy -- but I just typed them in to the Immediate Window. No, I got the
proper answer... as I said, I could not reproduce your results. But, I did
get an error when I copied and pasted your formula into the Immediate
Window. Not a wrong answer, an error.

After getting the spaces and characters right, here's what I copied and
pasted from the Immediate Window, that worked, on 8/25/2006:

? DateAdd ("m", 5, Date())
1/25/2007
? DatePart ("m", DateAdd ("m", 5, Date()))
1

Larry Linson
Microsoft Access MVP
 
A

Altair1972m

Larry, I appreciate the help.

I did find one of the problems was that it was a make-table query and as a
result, it could not do the calculation right.

What I did was created a select query to prepare the information, and a make
table query to write the infromation from the select query.

This also produced the wrong information, but when I mailmerged the word
file, the right dates appeared in the final product.

I assume your question marks are substitutions for fieldnames?
 

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