# How to encode date as input in neural network?

I am using neural networks to predict a time series. The question I'm facing now is how do I encode date/time/serial no. of each input set as an input to the neural network?

Should I use 1 of C encoding (used for encoding categories) as described here?

Or Should I just feed it the time (in milliseconds since 1-1-1970)?

Or is feeding it the time unnecessary as long as I feed it the rest of the data chronologically?

• I am not sure why you think feeding it the time unnecessary if you are using neural networks to predict a time series. – scaaahu Sep 27 '13 at 9:32
• there are many ways to encode dates/time. it would help to know the nature of the time series. it is not a priori something either to rule out, or rule in. – vzn Sep 27 '13 at 15:40
• @vzn I am trying to predict a financial time series in general. If that is helpful. – Shayan RC Sep 30 '13 at 8:53

you state in comments you're working on financial time series prediction. whether to include time or not in inputs is somewhat domain-dependent. in general its relevant if you have some kind of "cyclic" time component in your data. for example, maybe there is some weekly effect in your data if it is running over weeks, or some intraday effect if it spans a single day. then if you have many cycles, include an input that reflects the position in the cycle, eg from $[-1,1]$ or $[0,1]$ or say $sin(t)$.
if you find that theres a consistent trend eg either increasing or decreasing over time say $f(t)$ its more appropriate to extract that from the inputs prior to feeding the inputs via what is called "detrending". in other words you subtract the formula $f(t)$ for that underlying trend and predict the trend plus difference $d_t = f_t + g_t$ but the NN focuses only on the difference $g_t$, not the trend $f_t$.