MC Press Online Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Converting to UK dates (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Converting to UK dates
#121838
normanrae (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Converting to UK dates 5 Months, 2 Weeks ago Karma: 0  
This date conversion is driving me crazy! I have a date in a 10 byte *char field in US format. The value of the date is "10/31/2007". I need to convert this date to the UK display format also 10 byte *char field, so the value I want is "31/10/2007".
I am using the following:

EVAL UKDate = %char(%date(USdate:*usa/):*dmy/)

But this results in the value "31/10/07" (missing the century).

I tried *cdmy/ which returns "131/10/07" !!!!
I tried *eur/ which the compiler returns as invalid.
I tried *eur which returns the value "31.10.2007" (but I want "/" not"." )

Why cant I put a date format in the second parameter of the %CHAR that will return a UK date that contains the century?
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#121839
B.Robins (User)
Junior Boarder
Posts: 23
graphgraph
User Offline Click here to see the profile of this user
Re:Converting to UK dates 5 Months, 2 Weeks ago Karma: -1  
Norman,

You want the *Eur format, not *dmy.

As an aside, why not just use substring and concatenation operations instead of the dual conversion logic?

Bill
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#121840
normanrae (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Re:Converting to UK dates 5 Months, 2 Weeks ago Karma: 0  
Unfortunately *eur returns the value 31.10.2007 which is the European format, but not the UK format. what I need is 31/10/2007. What I really need is *dmyy or *dmcy, but seems like thats not an option.
Certainly I can, (and actually have) used concatenation to do this, but it just seems strange to me that such an obvious option is not available in the function. I mean, who needs *cdmy, but not *dmcy?
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#121844
sawofford (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re:Converting to UK dates 5 Months, 2 Weeks ago Karma: 0  
Seems like there should be a better option, but this will work and shouldn't be too hard to follow:
/Free
UKDate = %Xlate('.':'/':%char(%date:*eur));
/End-Free

That will however create problems if you need to convert back from that date character field to a date field, but you could reverse the process before the conversion.
 
Report to moderator   Logged Logged  
 
Last Edit: 2008/04/30 16:32 By sawofford.
  The administrator has disabled public write access.
#121845
sawofford (User)
Fresh Boarder
Posts: 3
graphgraph
User Offline Click here to see the profile of this user
Re:Converting to UK dates 5 Months, 2 Weeks ago Karma: 0  
Or better still create your own procedure/BIF to do the to/from conversion using this method.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop
   MC-STORE.COM