How to convert a date to a different format without making it a varchar?

169 views Asked by At

I have a date that looks like this: 29-DEC-2020 00:00
I want to format it to dd-mon like this: 29-DEC
How do I convert this without doing it with to_char()?

2

There are 2 answers

0
Gordon Linoff On

If your "date" looks like 29-DEC-2020 00:00, then it doesn't look like a date to me. It looks like a string.

So, you can use string functions:

substr(datecol, 6)

Of course, if it is really a date, you should either use to_char() or set the parameters to ignore the year in the UI. However, I strongly discourage you from doing that.

4
Koen Lostrie On

In apex, you can set the date format for your application in multiple places

  • For the entire app, go to "Application Definition Attributes" (1st entry in shared components) > "Globalization". There you have the option to choose the format mask for all different date datatypes. This will effect every occurence of this datatype in your application.
  • For a specific page item or for a report column, you can set the format mask under "Appearance" > "Format Mask"