1

I am looking to save and re-use dates which needs to be displayed in a format such as Oct. 25.

How do I do that please?

I read the documentation in datetime package. They do have shortmonthname which would display months by the abbreviation. They also allows storing and displaying stored dates. But I don't know how to combine the two.

  • datetime is 'obsolete',perhaps datetime2 is the better alternative – user31729 Oct 25 '15 at 21:03
  • @ChristianHupfer datetime2 has the advantage of being maintained. datetime has the advantage of working. ;) – cfr Oct 25 '15 at 21:17
  • @cfr: As I have shown in the answer (if that was requested at all) – user31729 Oct 25 '15 at 21:19
  • @ChristianHupfer Indeed. But why? Usually, you wouldn't write an answer using an obsolete package. If somebody asked for subfigure say, or times, you'd write an answer explaining how to use subcaption or subfig, perhaps, or one of the current Times-alike support packages. I'm just curious: if datetime2 is better, why not provide an answer with that? (I know why I wouldn't. I'm just curious why somebody would more-or-less say not to use datetime and then demonstrate how to use it.) [But ignore me: I'm irritated about datetime(2) and it is not your fault ;).] – cfr Oct 25 '15 at 21:27
  • @cfr: Because I've not used datetime2 so far and no time to read the manual ;-) – user31729 Oct 25 '15 at 21:28
4

With datetime dates can be stored to a symbolic name, say 'mydate' with \newsavedate{mydate}{daynumber}{monthnumber}{yearnumber}

\displaydate{mydate} will display this date using the current date format, whereas \getdatemonth{mydate} will extract the month of the saved date.

Using \shortmonthname[\getdatemonth{mydate}] it's possible to show the 3-letter abbreviation of the month (see the example)

\documentclass{article}

\usepackage{datetime}

\usepackage{xcolor}
\newdate{mydate}{23}{10}{2015}

\begin{document}
Not today: \displaydate{mydate}

The month of \displaydate{mydate} is \textcolor{red}{\shortmonthname[\getdatemonth{mydate}]}

\end{document}

enter image description here

Update

Using a \newdateformat any call to \mydateformat will show this format, that's why a 'wrapper macro' (or grouping) is appropiate:

\documentclass{article}

\usepackage{datetime}

\newdateformat{mydateformat}{\shortmonthname[\THEMONTH]. \THEDAY}
\newcommand{\myshortformat}[1]{%
{% group here!
  \mydateformat%
  \displaydate{#1}%
}%
}


\usepackage{xcolor}
\newdate{mydate}{23}{10}{2015}

\begin{document}
Not today: \displaydate{mydate}

The month of \displaydate{mydate} is \textcolor{red}{\shortmonthname[\getdatemonth{mydate}]}

The saved date was in (short format): \myshortformat{mydate}

Today is: \today

\end{document}

enter image description here

|improve this answer|||||
  • But how do you display Oct 25 from mydate? Are you suggesting making a new macro? – Argyll Oct 25 '15 at 22:25
  • @Argyll: I'll post an update in a few minutes – user31729 Oct 25 '15 at 22:25
  • @Argyll: See the update – user31729 Oct 25 '15 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.