Results 1 to 6 of 6

Thread: [CR 8.5]How convert data format to YYYY only

  1. #1

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    [CR 8.5]How convert data format to YYYY only

    Hi all,

    I have a report contains a field in date format

    Example : 21 / 08 / 2007

    I would like convert it to "mmm/yyyy"

    I use the code in edit formula like this

    Code:
        MonthName(Month({Table.Date1}),True) & " / " & year({Table.Date1})
    However, my return format is : Aug / 2007.00
    How can i make it return format = Aug / 2007


    Your help is much appreciated. Thanks you
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  2. #2

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: [CR 8.5]How convert data format to YYYY only

    i had solved the problem by using mid

    But i wondered is it the best solution.


    Code:
    MonthName(Month({Table.Date1}),True)& " / " & replace(mid(cstr(year({Table.Date1})),1,5),","," ")
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: [CR 8.5]How convert data format to YYYY only

    Crystal has a ToText function. The second argument of the function indicates how many decimal places to include.

    ToText(Year({Table1.Date}), 0)

  4. #4
    New Member
    Join Date
    Feb 2007
    Location
    Greenville, SC
    Posts
    13

    Re: [CR 8.5]How convert data format to YYYY only

    The solution that brucevde propsed also works with the Crystal Basic CStr function:

    CStr(Year({Table1.Date}), 0)

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [CR 8.5]How convert data format to YYYY only

    can't you just drop the date field onto the report and change it's format to display MM/YYYY? We do that a lot... esp in our report headers. We'll pass in a date as a parameter, like "8/1/2007", then in the report, drop the parameter onto the report, right-click, format (or it maybe properties), and set the format so that it gives "Aug 2007".

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

    Thread Starter
    Hyperactive Member nUflAvOrS's Avatar
    Join Date
    Jul 2007
    Location
    Malaysia/ Currently at Singapore
    Posts
    372

    Re: [CR 8.5]How convert data format to YYYY only

    Thanks svobill and brucedve, u shorted my coding

    techgnome u might misunderstood my problem or i didnt make it clearly i need to group it afterward, thanks you a lot....
    Where there is no hope, there can be no endeavor.

    There are two ways of rising in the world, either by your own industry or by the folly of others.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width