0

I have spent a fair couple of hours on this, including searching this forum, but I still haven't managed to solve my issue, therefore decided to ask a question here.

I am trying to run the following code:

\newcommand{\NewDocDate}{\today}
\newcommand{\PrevVersion}{\date}{06}{09}{2020}

And later in the doc, I call NewDocDate and PrevVersion. While the NewDocDate returns the correct date, the PrevVersion returns empty space. I have also tried using the following variations:

\newcommand{\PrevVersion}{date}{06}{09}{2020}

Which returned "date" when called. I also tried:

\newcommand{\PrevVersion}{\date}{06 June 2020}

Which returned empty space again.

I am using the package datetime using the command:

\usepackage{datetime}

PS: I am a noob...what am I doing wrong? Thank you so much for your time & help.

2
  • You need to add a backslash in front of the name of your new command, e.g. \newcommand{\NewDocDate}{\today}. \PrevVersion probably needs further adjustments. What do you expect \PrevVersion to do?
    – user263192
    Apr 29, 2022 at 10:23
  • Apologies, it was a typo, I do have the backslash in front of the \PrevVersion and \NewDocDate. Apr 29, 2022 at 10:34

1 Answer 1

1

Welcome to TeX SE!

Here my solution that I think solves your issue:

\documentclass{scrartcl}

\usepackage{datetime}

\newcommand{\NewDocDate}{\today}
\newdate{PrevVersionDate}{06}{09}{2020}%define date
\newcommand{\PrevVersion}{\displaydate{PrevVersionDate}}%assigne afformentioned date to a newcommand

\begin{document}

\NewDocDate

\PrevVersion

\end{document}

For the Future please post a complete minimal working example (MWE) that shows your problem (as I posted a MWE that solves the issue) as we don't have to guess which documentclass and maybe even other packages that might interfere with your problem you are using.

Screenshot of my Output: enter image description here I haven't applied any formatting to the output yet.

5
  • Would you mind adding a screenshot? This would be helpful, especially because the desired output is not yet clear.
    – user263192
    Apr 29, 2022 at 10:35
  • 1
    @user187803 please see my edited answer.
    – Lukas
    Apr 29, 2022 at 10:40
  • This has solved my problem, and I would have never figured this out by myself: so I would like to thank you for helping me save potentially hours of painful trial & error. PS: you have a "typo", i.e. "PrevVesrion" instead of "PrevVersion", could potentially cause issues for someone copy-pasting your code :) Apr 29, 2022 at 11:01
  • 1
    Thanks for the information, I corrected the typo! Sometimes it can be helpful to read/search the documentation of the respective package, e.g. over on CTAN, in this case the documentation can be found here.
    – Lukas
    Apr 29, 2022 at 12:05
  • 1
    Appreciate your help, Lukas, thank you so much. Have a great weekend. Apr 29, 2022 at 12:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .