Reputation: 11
How can I convert DATE format from this (mm/dd/yyyy
) to this format (dd/mm/yyyy
)?
Do I need to use to_char() function?
If I have to, how can i use it?
Upvotes: 0
Views: 3019
Reputation: 754870
Unless my memory is letting me down badly:
DEFINE date_val DATE
DEFINE str_date CHAR(10)
LET date_val = MDY(12, 25, 2014)
LET str_date = date_val USING "dd/mm/yyyy"
If you have a string in the 'mm/dd/yyyy' format and want a string in the 'dd/mm/yyyy' format, then:
DEFINE in_str CHAR(10)
DEFINE out_str CHAR(10)
LET in_str = "12/25/2014"
LET out_str = in_str[4,6], in_str[1,3], in_str[7,10]
I'm getting abominably rusty; I think those substrings are correct (using [start,end]
rather than [start,len]
or [start:end]
or …), but I reserve the right to be wrong on the details of the notation — the concept is correct.
Upvotes: 4