3

Default DATE format when displaying dates is DD/MM/YY

I want to change that to DD.MM.YYYY

This is just a simple program:

DEFINE VARIABLE daDate AS DATE NO-UNDO.

daDate = TODAY.

MESSAGE daDate.

Currently the output looks like this: 16/09/20

I tried adding FORMAT "99.99.9999" after the variable name like this: DEFINE VARIABLE daDate FORMAT "99.99.9999" AS DATE NO-UNDO. but it didn't change the output at all.

When I instead of MESSAGE use DISPLAY and then write it out with FORMAT, then it displays the correct format: DISPLAY daDate FORMAT "99.99.9999".

Am I doing something completely wrong or am I missing something?

Tom Bascom
  • 13,405
  • 2
  • 27
  • 33
Smokus
  • 149
  • 1
  • 9

2 Answers2

5

The expression you message will be converted to character first so instead you can take control over that conversion:

MESSAGE STRING(daDate,"99.99.9999").
Jensd
  • 7,886
  • 2
  • 28
  • 37
  • Damn, that was so easy. Thanks a bunch! – Smokus Sep 16 '20 at 11:58
  • 2
    You have other ways to get other formats if you need. There is a ISO-DATE function, which can be used as `ISO-DATE(daDate)` and returns date in format AAAA-MM-DD and also the functions YEAR, MONTH and DAY, which are used as same as ISO-DATE and returns, respectively, the year portion, the month portion and the day portion of your DATE variable in integer, allowing to format each one the way you need. Hope it helps. – Bruno Sep 17 '20 at 09:44
0
DEFINE VARIABLE hoy         AS CHARACTER    NO-UNDO.    
hoy =  STRING (DAY (TODAY), "99") + "." 
     + STRING (MONTH (TODAY), "99") + "."
     + STRING (YEAR (TODAY)) .
Message hoy.