How to put a Label/unique ID on Date-time in Database or when analyzing data with R/Python?
<p>I am looking for a general solution in the database.It could be oracle or SQL server or the operation could be done in R/Python when I will import the data to R/Python. I have a Date-time(D-M-YY) column I want to put a label on it according to month. Day part is static it is trimmed by first day of the month. the month and year part is variable. For example:</p>

<pre><code>Date    Label
1-1-16   1
1-2-16   2
1-3-16   3
1-4-16   4
.
.
.
</code></pre>

<p>Finally my friend help me to find a solution in R, which is very simple,</p>

<p>date_sample &lt;-c('1-1-2016','1-2-2016','1-3-2016','1-4-2016')</p>

<p>format(as.Date(date_sample,format = '%d-%m-%Y'),"%m")</p>

<p>It gives me output:
"01" "02" "03" "04"</p>

python sql