Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / August 2006

Tip: Looking for answers? Try searching our database.

Format date as "d mmm"

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robin Chapple - 05 Aug 2006 04:49 GMT
I have a birthday list which I need to publish without the birth year
displayed.

How do I show 1st Jan 1970 as 1st Jan?

Thanks,

Robin Chapple
tina - 05 Aug 2006 05:35 GMT
your subject line shows the correct formatting syntax. presumably you
wouldn't have posted a question unless that format was not returning the
value the way you want to see it, so suggest you explain what you've tried,
and where you tried it, and what return you *are* getting, so we can help
you troubleshoot.

hth

> I have a birthday list which I need to publish without the birth year
> displayed.
[quoted text clipped - 4 lines]
>
> Robin Chapple
Robin Chapple - 05 Aug 2006 07:35 GMT
The requirement is to sort a birthday list on month and day so that
the month is ignored. I have achieved that this way:

DayNo: DatePart("d",[Birthday])

MonthNo: DatePart("m",[Birthday])

I then sort on MonthNo and DayNo. These fields are not displayed.

I then need a field that shows the birthday without the year.

I have tried this:

Event: DatePart("d mmm",[Birthday])

which gives #error

Thanks for your interest.

Robin Chapple

>your subject line shows the correct formatting syntax. presumably you
>wouldn't have posted a question unless that format was not returning the
[quoted text clipped - 12 lines]
>>
>> Robin Chapple
tina - 05 Aug 2006 15:56 GMT
ok. from your example, it appears you're creating a calculated field in a
query. try the following, as

Event: Format([Birthday], "d mmm")

btw, rather than creating a Month field and a Day field in the query to sort
on, you can get the same month/day sort with the following calculated field,
as

SortBy: Format([Birthday],"mmdd")

hth

> The requirement is to sort a birthday list on month and day so that
> the month is ignored. I have achieved that this way:
[quoted text clipped - 33 lines]
> >>
> >> Robin Chapple
Robin Chapple - 05 Aug 2006 21:58 GMT
Thanks Tina,

That was what the doctor ordered and will be useful for other
applications.

Grateful thanks,

Robin Chapple

>ok. from your example, it appears you're creating a calculated field in a
>query. try the following, as
[quoted text clipped - 47 lines]
>> >>
>> >> Robin Chapple
tina - 06 Aug 2006 01:29 GMT
you're welcome  :)

> Thanks Tina,
>
[quoted text clipped - 56 lines]
> >> >>
> >> >> Robin Chapple
John Vinson - 05 Aug 2006 23:47 GMT
>The requirement is to sort a birthday list on month and day so that
>the month is ignored. I have achieved that this way:
[quoted text clipped - 4 lines]
>
>I then sort on MonthNo and DayNo. These fields are not displayed.

You can get both constraints met by using one calculated field:

HappyHappy: DateSerial(Year(Date()), Month([Birthday]),
Day([Birthday]))

Sort it directly (it will sort chronologically by birthday
anniversary), and set its Format property to "d mmm".

You can't easily get 1st, 2nd, 3rd etc. without a fair bit of VBA code
- there's no simple Format setting to do so.

                 John W. Vinson[MVP]
Robin Chapple - 06 Aug 2006 04:31 GMT
Thanks John,

This minor exercise has become very interesting.

Robin

>>The requirement is to sort a birthday list on month and day so that
>>the month is ignored. I have achieved that this way:
[quoted text clipped - 17 lines]
>
>                  John W. Vinson[MVP]
fredg - 05 Aug 2006 06:06 GMT
> I have a birthday list which I need to publish without the birth year
> displayed.
[quoted text clipped - 4 lines]
>
> Robin Chapple

Do you mean display it as 1 Jan or literally as 1st Jan?
Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Robin Chapple - 05 Aug 2006 12:22 GMT
1st Jan preferred but 1 Jan acceptable

>> I have a birthday list which I need to publish without the birth year
>> displayed.
[quoted text clipped - 6 lines]
>
>Do you mean display it as 1 Jan or literally as 1st Jan?
fredg - 05 Aug 2006 18:52 GMT
> 1st Jan preferred but 1 Jan acceptable
>
[quoted text clipped - 8 lines]
>>
>>Do you mean display it as 1 Jan or literally as 1st Jan?

To display the date of birth as 1st Jan:

Copy and Paste the below function into a new module.

Public Function DateOrdinalEnding(DateIn, MoIn As String)
' Will add an Ordinal ending to a date, i.e. 13th Jan, 2nd Feb, etc.
' MoIn determines Month Format, i.e. "mmm" for "Feb" or "mmmm" for
"February"

If IsNull(DateIn) Then
   DateOrdinalEnding = ""
   Exit Function
End If
Dim dteX As String
dteX = DatePart("d", DateIn)

dteX = dteX & Nz(Choose(IIf((Abs(dteX) Mod 100) \ 10 = 1, 0,
Abs(dteX)) Mod 10, "st", "nd", "rd"), "th")

DateOrdinalEnding = dteX & Format(DateIn, " " & MoIn)
End Function
==================

You can call it from a query:
BirthdayOn:DateOrdinalEnding([DateOfBirth],"mmm")

or directly in a report or on a form, using an unbound text control:
=DateOrdinalEnding([DateOfBirth],"mmm")

Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Robin Chapple - 05 Aug 2006 22:25 GMT
Fred,

I like the opportunity that this provides if I get it right. I've done
something wrong.

I think that I have followed your instructions with this result:

http://www.rotary9790.org.au/test/datefunction.html

I really would like this to work.

AND BTW the application locked and I had to use the Task manager to
exit.

Thanks,

Robin

>> 1st Jan preferred but 1 Jan acceptable
>>
[quoted text clipped - 37 lines]
>or directly in a report or on a form, using an unbound text control:
>=DateOrdinalEnding([DateOfBirth],"mmm")
fredg - 05 Aug 2006 23:51 GMT
> Fred,
>
[quoted text clipped - 55 lines]
>>or directly in a report or on a form, using an unbound text control:
>>=DateOrdinalEnding([DateOfBirth],"mmm")

The highlighted line that begins with
dteX = dteX & Nz(Choose ... etc. and the next line
Abs(dteX)) Mod ... etc. should be all on one long line.

Email messages are usually wrapped at about 70 or so characters, so
you always need to be careful when copying and pasting.
Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.