To create something like a diary, I am using a number of input files within 2 directories a MONTH directory named 01-12 and a day directory within each month...01-31
so
12/ (December) which has a file 12.tex which inputs 12/01/01.tex (there is also a 12/02/02.tex and so on...the day tex file calls a bunch of other files from the day directory)
The idea was to have currfile print out the the month directory name and the day directory name and so use that to create headers and chapter heads automatically. I would just need to put in the year and it wouldput the right day of the week and date on the correct page.
I started exploring this here: Using macros in Memoir chapter for a Diary but changed my method a bit and using this answer to my last question:
https://tex.stackexchange.com/a/220450/26651
I thought I had my solution...
I tried this:
\DeclareRobustCommand{\dateforheader}{\formatdate{\StrBehind{\currfiledir}{/}[\currfilesubdir]\StrBefore{\currlastdir}{/}}{\StrBefore{\parentfiledir}{/}}{2015}}
and I tried this
\DeclareRobustCommand{\MyDay}{{\StrBehind{\currfiledir}{/}[\currfilesubdir]\StrBefore{\currlastdir}{/}}
\DeclareRobustCommand{\MyMonth}{\StrBefore{\parentfiledir}{/}}
\formatdate{\MyDay}{\MyMonth}{2015}
hoping to use them in a page header
\makeoddhead{mypagestyle}{}{\dateforheader}{\thepage}
This doesn't work.
nor does it work to just use the macro on the 12/01/01.tex page:
\dateforheader
though
\MyDay
\MyMonth
will work by themselves
my error messages:
./12/1/1.tex:4: Missing number, treated as zero. [{\dateforheader]
./12/1/1.tex:4: Undefined control sequence. [{\dateforheader]
./12/1/1.tex:4: Missing number, treated as zero. [{\dateforheader]
./12/1/1.tex:4: Missing number, treated as zero. [{\dateforheader]
./12/1/1.tex:4: Undefined control sequence. [{\dateforheader]
./12/1/1.tex:4: Missing number, treated as zero. [{\dateforheader]
./12/1/1.tex:4: Package datetime Error: Invalid Month number 0. [{\dateforheader]
UPDATE:
using @karlkoeller answer below I created a MWE but it doesn't seem to work for me so I thought I would test the individual macros using the MWE below:
Set up home directory inside is test.tex with this code:
\documentclass{memoir}
\usepackage{xstring}
\usepackage{datetime}
\usepackage{currfile}
\usepackage{import}
\StrBehind{\currfiledir}{/}[\currfilesubdir]
\StrBefore{\currfilesubdir}{/}[\MyDay]
\StrBefore{\currfiledir}{/}[\MyMonth]
\newcommand{\mydate}{\MyDay, \MyMonth}
\begin{document}
\input{8/8.tex}
\end{document}
within the home directory there is a directory called 8 within that
a tex file called 8.tex with the following code:
\input{8/1/1.tex}
also witin directory 8 is directory 1 with the 1.tex file with the code below... which I thought would test the marcros:
currfiledir:\currfiledir
part 1 of My Day: \StrBehind{\currfiledir}{/}
part 2 of My Day: \StrBefore{\currfilesubdir}{/}
MyMonth: \StrBefore{\currfiledir}{/}
date: \mydate
the results are below:
currfiledir: 8/1/
part 1 of My Day: 1/
part 2 of My Day:
MyMonth: 8
date: ,
any ideas what is wrong here?

\MyDaydoesn't work. And then you say it does. It would be helpful if you posted a complete MWE with everything in one place. – cfr Jan 04 '15 at 04:18