Date format help

R

Ray S.

From the input of a date in short format, say 5/1/2005, I want to output the
name of the month. For example, May. I made a small table with the names of
the months and the corresponding numbers, and I'm trying to use DLookup, but
I'm having trouble figuring out what to do with the months represented by two
digits. Is there an easy function that will do this?

I tried to work with this:

Left$(DLookUp("[Month_Name]","[tbl_Months_of_the_Year]","[Month_Number]=string(1,left$([txtDate],1))"),3) & (Right$(txtDate],2))

where the txtDate is in the mm/dd/yyyy format

Will this work when the month has two digits?
 
D

Dennis

You don't need to use a DLookUp to get the month. In the control source of
the box you want to display the month in put this
=Format(txtDate,"mmmm")
 
R

Ray S.

Thanks Dennis, but I don't want to display the month in a box. I'm actually
going to concatenate the month name from the first part of the date that has
been input into a form, transformed into a three character name from the
mm/dd/yyyy format, with the two last digits of the year and another part of
an alphabetic term from another source. I can't figure how to use your
suggestion for that.

Dennis said:
You don't need to use a DLookUp to get the month. In the control source of
the box you want to display the month in put this
=Format(txtDate,"mmmm")

Ray S. said:
From the input of a date in short format, say 5/1/2005, I want to output the
name of the month. For example, May. I made a small table with the names of
the months and the corresponding numbers, and I'm trying to use DLookup, but
I'm having trouble figuring out what to do with the months represented by two
digits. Is there an easy function that will do this?

I tried to work with this:

Left$(DLookUp("[Month_Name]","[tbl_Months_of_the_Year]","[Month_Number]=string(1,left$([txtDate],1))"),3) & (Right$(txtDate],2))

where the txtDate is in the mm/dd/yyyy format

Will this work when the month has two digits?
 
D

Dennis

Format(txtDate,"mmm") & Right("0" & CStr(Year(txtDate)-2000),2) & "Other"

Ray S. said:
Thanks Dennis, but I don't want to display the month in a box. I'm actually
going to concatenate the month name from the first part of the date that has
been input into a form, transformed into a three character name from the
mm/dd/yyyy format, with the two last digits of the year and another part of
an alphabetic term from another source. I can't figure how to use your
suggestion for that.

Dennis said:
You don't need to use a DLookUp to get the month. In the control source of
the box you want to display the month in put this
=Format(txtDate,"mmmm")

Ray S. said:
From the input of a date in short format, say 5/1/2005, I want to output the
name of the month. For example, May. I made a small table with the names of
the months and the corresponding numbers, and I'm trying to use DLookup, but
I'm having trouble figuring out what to do with the months represented by two
digits. Is there an easy function that will do this?

I tried to work with this:

Left$(DLookUp("[Month_Name]","[tbl_Months_of_the_Year]","[Month_Number]=string(1,left$([txtDate],1))"),3) & (Right$(txtDate],2))

where the txtDate is in the mm/dd/yyyy format

Will this work when the month has two digits?
 
R

Ray S.

OK Dennis, it works; but could you please try to give me a little explanation
of it.

Dennis said:
Format(txtDate,"mmm") & Right("0" & CStr(Year(txtDate)-2000),2) & "Other"

Ray S. said:
Thanks Dennis, but I don't want to display the month in a box. I'm actually
going to concatenate the month name from the first part of the date that has
been input into a form, transformed into a three character name from the
mm/dd/yyyy format, with the two last digits of the year and another part of
an alphabetic term from another source. I can't figure how to use your
suggestion for that.

Dennis said:
You don't need to use a DLookUp to get the month. In the control source of
the box you want to display the month in put this
=Format(txtDate,"mmmm")

:

From the input of a date in short format, say 5/1/2005, I want to output the
name of the month. For example, May. I made a small table with the names of
the months and the corresponding numbers, and I'm trying to use DLookup, but
I'm having trouble figuring out what to do with the months represented by two
digits. Is there an easy function that will do this?

I tried to work with this:

Left$(DLookUp("[Month_Name]","[tbl_Months_of_the_Year]","[Month_Number]=string(1,left$([txtDate],1))"),3) & (Right$(txtDate],2))

where the txtDate is in the mm/dd/yyyy format

Will this work when the month has two digits?
 
R

Ray S.

I figured it out. Thanks.

Ray S. said:
OK Dennis, it works; but could you please try to give me a little explanation
of it.

Dennis said:
Format(txtDate,"mmm") & Right("0" & CStr(Year(txtDate)-2000),2) & "Other"

Ray S. said:
Thanks Dennis, but I don't want to display the month in a box. I'm actually
going to concatenate the month name from the first part of the date that has
been input into a form, transformed into a three character name from the
mm/dd/yyyy format, with the two last digits of the year and another part of
an alphabetic term from another source. I can't figure how to use your
suggestion for that.

:

You don't need to use a DLookUp to get the month. In the control source of
the box you want to display the month in put this
=Format(txtDate,"mmmm")

:

From the input of a date in short format, say 5/1/2005, I want to output the
name of the month. For example, May. I made a small table with the names of
the months and the corresponding numbers, and I'm trying to use DLookup, but
I'm having trouble figuring out what to do with the months represented by two
digits. Is there an easy function that will do this?

I tried to work with this:

Left$(DLookUp("[Month_Name]","[tbl_Months_of_the_Year]","[Month_Number]=string(1,left$([txtDate],1))"),3) & (Right$(txtDate],2))

where the txtDate is in the mm/dd/yyyy format

Will this work when the month has two digits?
 

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