INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Display mmddyyyy-mmddyyyy database date range field to display in alphanumerical format

Display mmddyyyy-mmddyyyy database date range field to display in alphanumerical format

Display mmddyyyy-mmddyyyy database date range field to display in alphanumerical format

(OP)
Crystal Reports 10
MS SQL Server 2008 R2

How do I convert a database date range field (format mm/dd/yyyy-mm/dd/yyyy) to display as, e.g.,

October 24th through November 4th, 2016


Thanks in advance!

RE: Display mmddyyyy-mmddyyyy database date range field to display in alphanumerical format

Getting the month (monthname function) and year (year function). The day is tricky since it can be a suffix of st, nd, rd or th. But a if or switch statement might work for this.

i.e., monthname(datefield)+ ' ' + totext(day(datefield))+if day(datefield) = 1 then 'st ' else if day(datefield) =2 then 'nd ' else if day(datefield) = 3 the 'rd ' else 'th ' +year(datefield) + ' through ' + (repeat the first part of the formula for the second datefield.

RE: Display mmddyyyy-mmddyyyy database date range field to display in alphanumerical format

(OP)
Thanks, kray4660.

It's tricky since it's a range. I'm creating formulae, breaking down each piece w/left and mid functions (and of course days could be one or two chars so must allow for that). Just looking for a more elegant approach than mine :)

I'll give your ideas a try!

hmax

RE: Display mmddyyyy-mmddyyyy database date range field to display in alphanumerical format

Unfortunately for what you are doing, I do not know of a more elegant solution. Even if you are just using one field, you can use the minimum and maximum functions to get the start and end dates.

RE: Display mmddyyyy-mmddyyyy database date range field to display in alphanumerical format

"For the period "&minimum({?Date Range})&" thru "&maximum({?Date Range})

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close