Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Breaking up a data value (date) Post Reply Post New Topic
Author Message
barfnuts
Newbie
Newbie
Avatar

Joined: 11 Sep 2008
Location: Canada
Online Status: Offline
Posts: 4
Quote barfnuts Replybullet Topic: Breaking up a data value (date)
    Posted: 11 Sep 2008 at 1:23pm
Hello everyone,

I'm trying to integrate UPS and our inventory system using Crystal. I have everything set up properly but I'm having one problem that I'd like to try and fix.

One of UPS's values in their database is called "Collection Date", which is a date/timestamp of when a waybill was printed. I'd like to use this value as a shipping date, however the way that they have the record structured is not really helping; they put the date and time in one long number string. For example, if the date was August 20th, 2008, printed at 2:14pm with 15 seconds, the string would read: 20080820141415.

Is there any way that I can break up this one string so that I can display the date only? And preferably structure it in a way that I can have the date displayed in yyyy/mm/dd format?

Thanks in advance for any replies.


IP IP Logged
Savan
Senior Member
Senior Member
Avatar

Joined: 14 Dec 2007
Location: India
Online Status: Offline
Posts: 162
Quote Savan Replybullet Posted: 12 Sep 2008 at 2:52am

u can do this way

mid(totext(<fieldname>,)1,4)&"/"&mid(totext(<fieldname>),5,2)&"/"&mid(totext(<fieldname>),7,2)
 
You can find many such formulas and other tricks in Brian's book "Crysta Reports Encylopedia"


Edited by Savan - 12 Sep 2008 at 2:52am
Thanks
Savan
IP IP Logged
barfnuts
Newbie
Newbie
Avatar

Joined: 11 Sep 2008
Location: Canada
Online Status: Offline
Posts: 4
Quote barfnuts Replybullet Posted: 12 Sep 2008 at 11:36am
Thanks for your reply, however since I use Crystal Reports maybe once every six months then I wouldn't have much use for the book, although i'm sure it's very good.

This is the formula that I'm now using:

if {UPS_CSV_EXPORT_csv.TRACKING NUMBER} = "" then "Not Shipped" else mid(totext({UPS_CSV_EXPORT_csv.SHIP DATE}),4,2) & "/" & mid(totext({UPS_CSV_EXPORT_csv.SHIP DATE}),6,2) & "/" & left(totext({UPS_CSV_EXPORT_csv.SHIP DATE}),4)

The value in the CSV file is: 20080829113825
The value that Crystal reports back is: 08/0,/20,0

Very bizarre. Any ideas?

Thanks,
Travis

IP IP Logged
barfnuts
Newbie
Newbie
Avatar

Joined: 11 Sep 2008
Location: Canada
Online Status: Offline
Posts: 4
Quote barfnuts Replybullet Posted: 12 Sep 2008 at 3:09pm
Ahhh never mind, fixed it. Apparently Crystal was putting commas in the number field and when I converted it to a string, it was included. The code that fixed it was:

mid(totext({UPS_CSV_EXPORT_csv.SHIP DATE},0,""),5,2) & "/" & mid(totext({UPS_CSV_EXPORT_csv.SHIP DATE},0,""),7,2) & "/" & left(totext({UPS_CSV_EXPORT_csv.SHIP DATE},0,""),4)

Thanks everyone!
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.000 seconds.