Message Boards Message Boards

Convert dates on Timeline?

GROUPS:

Dear All,

Please can you help. Why are 'DateFormat' not properly working on the 'Timeline' output?

The date output should be "Day", "Month" and "Year". But only work on the first output '04/09/2004' but not on the following two dates. Why?

Please can you help. Thanks. ....Jos

DateObject[DateFormat -> {"Day", "/", "Month", "/", "Year"}] ;
TimelinePlot[
 {{
   Labeled[{2004, 04, 09}, Style["Date output OK", Black, Bold, 12]]
   , Labeled[Interval[{{2005, 18, 02}, {2005, 28, 06}}], 
    Style["Date output not OK\nshould be\n18/02/2005 - 28/06/2005", 
     Red, Bold, 12]]
   , Labeled[Interval[{{2012, 01, 08}, {2015, 31, 12}}], 
    Style["Date output not OK\nshould be\n08/01/2012 - 31/12/2015", 
     Red, Bold, 12]]
   }
  }]

enter image description here

POSTED BY: Jos Klaps
Answer
13 days ago

Your first line:

DateObject[DateFormat -> {"Day", "/", "Month", "/", "Year"}] ;

Doesn't do anything…

Have a look at the help of timeline. The default interpretation of a list as a date is {y,m,d,h,m,s}. If you want to specify it differently use e.g. DateObjects:

DateObject[{"2005/18/02", {"Year", "/", "Month", "/", "Day"}}]
POSTED BY: Sander Huisman
Answer
13 days ago

Instead of: DateObject[DateFormat -> {"Day", "/", "Month", "/", "Year"}] ;

You want: SetOptions[DateObject, DateFormat -> {"Day", "/", "Month", "/", "Year"}]

Additionally, you will still have to specify your dates in code as {year,month,day}. DateFormat just affects how dates are displayed. Look at the output of DateObject[{2015, 31, 12}]. It interprets this as 31 months and 12 days beyond the year 2015.

POSTED BY: Sean Clarke
Answer
13 days ago

Dear Sander, Sean,

Thanks for your quick reply and excellent support.

Best Regards,...Jos

POSTED BY: Jos Klaps
Answer
12 days ago

Group Abstract Group Abstract