CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Help - Need date conversion

    I am trying to convert a numeric field of data from a number to a date format so that I can filter by the date. As an example, my date comes in to Crystal as an 8 digit number. ex. 02062012. I need to convert that to a date field, preferably 02/06/2012 or with dots. Makes no difference. What I need to be able to do in the end is to run reports that I can then filter by date. Essentially I need an aging report, but I can't seem to figure out the right formula.

    Please help!

    thanks,

    Jason

  2. #2
    Join Date
    Jul 2005
    Posts
    1,083

    Re: Help - Need date conversion

    Welcome to CodeGuru forums!

    1.- Convert numericfield to string field
    2.- Apply Date function giving year, month and day in numeric way
    Code:
    StringVar DateString := ToText({YourTable.YourNumericField},"00000000");
    DateVar DateDate := Date(ToNumber(Mid(DateString,5,4)), ToNumber(Mid(DateString,1,2)), ToNumber(Mid(DateString,3,2)));
    DateDate;
    (DateString & DateDate are variable's names, could be whichever you like)
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

Tags for this Thread

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

Featured