Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting a date

Status
Not open for further replies.

Rachel30

Programmer
Mar 1, 2005
95
GB
Hi,

I have a date field I would like to format the date to come out as:-

Monday 1st May 2005. This is not available in the format date section. Do you have anydea's how I format this thanks Rachel.
 
You could try the following which adapts Vidru's solution from thread767-733334 for the numeric suffixes:

weekdayname(dayofweek({table.date})) +" "+ totext({table.date},"d")+
(
if datepart("d",{table.date}) in [1,21,31] then "st "
else if datepart("d",{table.date}) in [2,22] then "nd "
else if datepart("d",{table.date}) in [3,23] then "rd "
else "th "
)+
totext({table.date},"MMMM yyyy")

-LB
 
The only tricky part is using 1st, 2nd, etc.

I have posted before with a series of IFs to handle this but I can't find the post now.

Anyway, try a formula containing:

weekdayname(dayofweek(cdate(2001,1,23)))

To get the day of the week, drop it into a text object, then drop the date in alongside and format the date to display as 1st May 2005

Or use:

weekdayname(dayofweek(currentdate))&" "&totext(day(currentdate),0,"")&" "&monthname(month(currentdate))&" "&totext(year(currentdate),0,"")

Replace currentdate with your date.

Again, to get the 1st, 2nd, etc., I think that you'll need to create a formula such as:

stringvar Addendum;
if day(currentdate) = 1 then
Addendum:="st"
else
if day(currentdate) = 2 then
Addendum:="nd"
etc...

Then reference the addendum after the day portion in the formula above.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top