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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format date to 2-digit year (M/d/yy)

Status
Not open for further replies.

pb100

Programmer
Aug 31, 2006
36
US
Thought I would post this tip as I figured out the answer by trying different options after reading through several posts. I could not find a straightforward answer so hopefully putting it here will help someone else.

I use CRXI and SQL 2005 and had a report with a text field description of several different strings concatenated together. The date was showing up in that string with a 4-digit year and my customer wanted only 2 digits. Here's how I solved it:

{stringA} & totext(date({datefield}), "M/d/yy") & {stringB}

The key was to put the M as an uppercase M. Works great now!
 
Yes, a lowercase 'm' returns minutes - uppercase 'M' returns the month.

Watch out for nulls when concatenating strings...

- Ido

view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Or you can drop all 3 items into a text box, then right click the date portion and format it however you'd like.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top