Converting to UK dates (1 viewing) (1) Guest
Favoured: 0
|
|
|
TOPIC: Converting to UK dates
|
|
|
|
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?
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
B.Robins (User)
Junior Boarder
Posts: 23
|
|
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
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
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?
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
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.
|
|
|
|
|
|
|
Last Edit: 2008/04/30 16:32 By sawofford.
|
|
|
The administrator has disabled public write access.
|
|
|
|
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.
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
|