WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Date Format

 
Goto page Previous  1, 2
   Home -> Office other -> General Discussions RSS
Next:  Record Selector  
Author Message
Tom Wickerath

External


Since: Mar 03, 2006
Posts: 1491



(Msg. 9) Posted: Fri Mar 24, 2006 12:06 am
Post subject: RE: Date Format [Login to view extended thread Info.]
Archived from groups: microsoft>public>access (more info?)

***Repost--I don't see a copy of a reply I sent earlier***

Hi Fel,

I'm not sure what I'm doing wrong, but I can't get the query-only based
method to work, specifically for the 11th, 12th and 13th of the month. I made
some modifications to the function that I referenced earlier, which are shown
below. Try the following as an experiment:

1.) Create a table named Orders, with a field named ShippedDate.

2.) Add one record for each day of the month, for a month that includes 31
days, such as July. Just for fun, add one more record that does not include a
date in the ShippedDate field (null).

3.) Copy the following SQL statement and paste it into a new query:

SELECT Orders.ShippedDate,
Day([ShippedDate]) & fncOrdinal([ShippedDate])
AS DayOfMonthFunction,
Day([ShippedDate]) & Nz(Choose(1+Day([ShippedDate]) Mod
10,"th","st","nd","rd"),"th")
AS DayOfMonthSQL,
IIf(Day([ShippedDate]) & fncOrdinal([ShippedDate])=Day([ShippedDate]) &
Nz(Choose(1+Day([ShippedDate]) Mod 10,"th","st","nd","rd"),"th"),"Yes","NO")
AS [Are They Equal?]
FROM Orders
ORDER BY Orders.ShippedDate;

4.) Copy the following function into a new module. Name the module something
like basDateOrdinal (just don't name it the same as the function):

'*******************Begin Code*********************
Option Compare Database
Option Explicit

Function fncOrdinal(ByVal varDate As Variant) As String

Dim intNumber As Integer

If Not IsNull(varDate) Then
intNumber = Day(varDate)

Select Case Right$(intNumber, 1)
Case "1"
If Right$(intNumber, 2) = "11" Then
fncOrdinal = "th"
Else
fncOrdinal = "st"
End If
Case "2"
If Right$(intNumber, 2) = "12" Then
fncOrdinal = "th"
Else
fncOrdinal = "nd"
End If
Case "3"
If Right$(intNumber, 2) = "13" Then
fncOrdinal = "th"
Else
fncOrdinal = "rd"
End If
Case Else
fncOrdinal = "th"
End Select
End If

End Function

'*******************End Code**********************

5.) Run the query. I think you will see how the SQL only solution leaves
something to be desired, especially for the 11, 12 and 13th of the month.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

"fel" wrote:

> Tom, I had it figured out in query based. It works perfectly well. Lots of
> thanks.
>
> Fel
Back to top
Login to vote
fel

External


Since: Mar 23, 2006
Posts: 6



(Msg. 10) Posted: Fri Mar 24, 2006 5:51 am
Post subject: RE: Date Format [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Tom, really appreciate your asisstance. But I still can't get the desired
results. Perhaps I will have to rephrase the sentence structure which don't
require me to have a suffix behind the dates.

Thanks anyway, Fel

"Tom Wickerath" wrote:

> ***Repost--I don't see a copy of a reply I sent earlier***
>
> Hi Fel,
>
> I'm not sure what I'm doing wrong, but I can't get the query-only based
> method to work, specifically for the 11th, 12th and 13th of the month. I made
> some modifications to the function that I referenced earlier, which are shown
> below. Try the following as an experiment:
>
> 1.) Create a table named Orders, with a field named ShippedDate.
>
> 2.) Add one record for each day of the month, for a month that includes 31
> days, such as July. Just for fun, add one more record that does not include a
> date in the ShippedDate field (null).
>
> 3.) Copy the following SQL statement and paste it into a new query:
>
> SELECT Orders.ShippedDate,
> Day([ShippedDate]) & fncOrdinal([ShippedDate])
> AS DayOfMonthFunction,
> Day([ShippedDate]) & Nz(Choose(1+Day([ShippedDate]) Mod
> 10,"th","st","nd","rd"),"th")
> AS DayOfMonthSQL,
> IIf(Day([ShippedDate]) & fncOrdinal([ShippedDate])=Day([ShippedDate]) &
> Nz(Choose(1+Day([ShippedDate]) Mod 10,"th","st","nd","rd"),"th"),"Yes","NO")
> AS [Are They Equal?]
> FROM Orders
> ORDER BY Orders.ShippedDate;
>
> 4.) Copy the following function into a new module. Name the module something
> like basDateOrdinal (just don't name it the same as the function):
>
> '*******************Begin Code*********************
> Option Compare Database
> Option Explicit
>
> Function fncOrdinal(ByVal varDate As Variant) As String
>
> Dim intNumber As Integer
>
> If Not IsNull(varDate) Then
> intNumber = Day(varDate)
>
> Select Case Right$(intNumber, 1)
> Case "1"
> If Right$(intNumber, 2) = "11" Then
> fncOrdinal = "th"
> Else
> fncOrdinal = "st"
> End If
> Case "2"
> If Right$(intNumber, 2) = "12" Then
> fncOrdinal = "th"
> Else
> fncOrdinal = "nd"
> End If
> Case "3"
> If Right$(intNumber, 2) = "13" Then
> fncOrdinal = "th"
> Else
> fncOrdinal = "rd"
> End If
> Case Else
> fncOrdinal = "th"
> End Select
> End If
>
> End Function
>
> '*******************End Code**********************
>
> 5.) Run the query. I think you will see how the SQL only solution leaves
> something to be desired, especially for the 11, 12 and 13th of the month.
>
>
> Tom
>
> http://www.access.qbuilt.com/html/expert_contributors.html
> http://www.access.qbuilt.com/html/search.html
> __________________________________________
>
> "fel" wrote:
>
> > Tom, I had it figured out in query based. It works perfectly well. Lots of
> > thanks.
> >
> > Fel
Back to top
Login to vote
RPage

External


Since: Apr 29, 2006
Posts: 1



(Msg. 11) Posted: Sat Apr 29, 2006 1:08 am
Post subject: RE: Date Format [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Fel,
I'm new to Access, but I had the same need as you. After a lot of tinkering,
I think I got all of the dates to work with the following. You'll have to add
the space and the month after this, but this gets the days displaying
correctly.

=IIf(Format([Date],"dd")=11,"11th",(IIf(Format([Date],"dd")=12,"12th",(IIf(Format([Date],"dd")=13,"13th",(Day([Date])
& Nz(Choose(1+Day([Date]) Mod 10,"th","st","nd","rd"),"th")))))))

I hope it works for you. I also hope I posted the reply correctly since this
is my first time.

Richard Page


"fel" wrote:

> Tom, really appreciate your asisstance. But I still can't get the desired
> results. Perhaps I will have to rephrase the sentence structure which don't
> require me to have a suffix behind the dates.
>
> Thanks anyway, Fel
>
> "Tom Wickerath" wrote:
>
> > ***Repost--I don't see a copy of a reply I sent earlier***
> >
> > Hi Fel,
> >
> > I'm not sure what I'm doing wrong, but I can't get the query-only based
> > method to work, specifically for the 11th, 12th and 13th of the month. I made
> > some modifications to the function that I referenced earlier, which are shown
> > below. Try the following as an experiment:
> >
> > 1.) Create a table named Orders, with a field named ShippedDate.
> >
> > 2.) Add one record for each day of the month, for a month that includes 31
> > days, such as July. Just for fun, add one more record that does not include a
> > date in the ShippedDate field (null).
> >
> > 3.) Copy the following SQL statement and paste it into a new query:
> >
> > SELECT Orders.ShippedDate,
> > Day([ShippedDate]) & fncOrdinal([ShippedDate])
> > AS DayOfMonthFunction,
> > Day([ShippedDate]) & Nz(Choose(1+Day([ShippedDate]) Mod
> > 10,"th","st","nd","rd"),"th")
> > AS DayOfMonthSQL,
> > IIf(Day([ShippedDate]) & fncOrdinal([ShippedDate])=Day([ShippedDate]) &
> > Nz(Choose(1+Day([ShippedDate]) Mod 10,"th","st","nd","rd"),"th"),"Yes","NO")
> > AS [Are They Equal?]
> > FROM Orders
> > ORDER BY Orders.ShippedDate;
> >
> > 4.) Copy the following function into a new module. Name the module something
> > like basDateOrdinal (just don't name it the same as the function):
> >
> > '*******************Begin Code*********************
> > Option Compare Database
> > Option Explicit
> >
> > Function fncOrdinal(ByVal varDate As Variant) As String
> >
> > Dim intNumber As Integer
> >
> > If Not IsNull(varDate) Then
> > intNumber = Day(varDate)
> >
> > Select Case Right$(intNumber, 1)
> > Case "1"
> > If Right$(intNumber, 2) = "11" Then
> > fncOrdinal = "th"
> > Else
> > fncOrdinal = "st"
> > End If
> > Case "2"
> > If Right$(intNumber, 2) = "12" Then
> > fncOrdinal = "th"
> > Else
> > fncOrdinal = "nd"
> > End If
> > Case "3"
> > If Right$(intNumber, 2) = "13" Then
> > fncOrdinal = "th"
> > Else
> > fncOrdinal = "rd"
> > End If
> > Case Else
> > fncOrdinal = "th"
> > End Select
> > End If
> >
> > End Function
> >
> > '*******************End Code**********************
> >
> > 5.) Run the query. I think you will see how the SQL only solution leaves
> > something to be desired, especially for the 11, 12 and 13th of the month.
> >
> >
> > Tom
> >
> > http://www.access.qbuilt.com/html/expert_contributors.html
> > http://www.access.qbuilt.com/html/search.html
> > __________________________________________
> >
> > "fel" wrote:
> >
> > > Tom, I had it figured out in query based. It works perfectly well. Lots of
> > > thanks.
> > >
> > > Fel
Back to top
Login to vote
ms saintclair

External


Since: Nov 20, 2009
Posts: 1



(Msg. 12) Posted: Fri Nov 20, 2009 11:01 am
Post subject: RE: Date Format [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

RPage,
Thanks, that was extrememly helpful, thank you!

"RPage" wrote:

> Fel,
> I'm new to Access, but I had the same need as you. After a lot of tinkering,
> I think I got all of the dates to work with the following. You'll have to add
> the space and the month after this, but this gets the days displaying
> correctly.
>
> =IIf(Format([Date],"dd")=11,"11th",(IIf(Format([Date],"dd")=12,"12th",(IIf(Format([Date],"dd")=13,"13th",(Day([Date])
> & Nz(Choose(1+Day([Date]) Mod 10,"th","st","nd","rd"),"th")))))))
>
> I hope it works for you. I also hope I posted the reply correctly since this
> is my first time.
>
> Richard Page
>
>
> "fel" wrote:
>
> > Tom, really appreciate your asisstance. But I still can't get the desired
> > results. Perhaps I will have to rephrase the sentence structure which don't
> > require me to have a suffix behind the dates.
> >
> > Thanks anyway, Fel
> >
> > "Tom Wickerath" wrote:
> >
> > > ***Repost--I don't see a copy of a reply I sent earlier***
> > >
> > > Hi Fel,
> > >
> > > I'm not sure what I'm doing wrong, but I can't get the query-only based
> > > method to work, specifically for the 11th, 12th and 13th of the month. I made
> > > some modifications to the function that I referenced earlier, which are shown
> > > below. Try the following as an experiment:
> > >
> > > 1.) Create a table named Orders, with a field named ShippedDate.
> > >
> > > 2.) Add one record for each day of the month, for a month that includes 31
> > > days, such as July. Just for fun, add one more record that does not include a
> > > date in the ShippedDate field (null).
> > >
> > > 3.) Copy the following SQL statement and paste it into a new query:
> > >
> > > SELECT Orders.ShippedDate,
> > > Day([ShippedDate]) & fncOrdinal([ShippedDate])
> > > AS DayOfMonthFunction,
> > > Day([ShippedDate]) & Nz(Choose(1+Day([ShippedDate]) Mod
> > > 10,"th","st","nd","rd"),"th")
> > > AS DayOfMonthSQL,
> > > IIf(Day([ShippedDate]) & fncOrdinal([ShippedDate])=Day([ShippedDate]) &
> > > Nz(Choose(1+Day([ShippedDate]) Mod 10,"th","st","nd","rd"),"th"),"Yes","NO")
> > > AS [Are They Equal?]
> > > FROM Orders
> > > ORDER BY Orders.ShippedDate;
> > >
> > > 4.) Copy the following function into a new module. Name the module something
> > > like basDateOrdinal (just don't name it the same as the function):
> > >
> > > '*******************Begin Code*********************
> > > Option Compare Database
> > > Option Explicit
> > >
> > > Function fncOrdinal(ByVal varDate As Variant) As String
> > >
> > > Dim intNumber As Integer
> > >
> > > If Not IsNull(varDate) Then
> > > intNumber = Day(varDate)
> > >
> > > Select Case Right$(intNumber, 1)
> > > Case "1"
> > > If Right$(intNumber, 2) = "11" Then
> > > fncOrdinal = "th"
> > > Else
> > > fncOrdinal = "st"
> > > End If
> > > Case "2"
> > > If Right$(intNumber, 2) = "12" Then
> > > fncOrdinal = "th"
> > > Else
> > > fncOrdinal = "nd"
> > > End If
> > > Case "3"
> > > If Right$(intNumber, 2) = "13" Then
> > > fncOrdinal = "th"
> > > Else
> > > fncOrdinal = "rd"
> > > End If
> > > Case Else
> > > fncOrdinal = "th"
> > > End Select
> > > End If
> > >
> > > End Function
> > >
> > > '*******************End Code**********************
> > >
> > > 5.) Run the query. I think you will see how the SQL only solution leaves
> > > something to be desired, especially for the 11, 12 and 13th of the month.
> > >
> > >
> > > Tom
> > >
> > > http://www.access.qbuilt.com/html/expert_contributors.html
> > > http://www.access.qbuilt.com/html/search.html
> > > __________________________________________
> > >
> > > "fel" wrote:
> > >
> > > > Tom, I had it figured out in query based. It works perfectly well. Lots of
> > > > thanks.
> > > >
> > > > Fel
Back to top
Login to vote
Display posts from previous:   
       Home -> Office other -> General Discussions All times are: Eastern Time (US & Canada) (change)
Goto page Previous  1, 2
Page 2 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
 Office
  Office Other
 Security
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET |
  • IT Support