title: VB.net Minus 1 year from DateTime.Now.ToString
body: <p>Based on my previous question, <a href="https://stackoverflow.com/questions/33586341/vb-net-sql-statement-to-query-1-yr-old-timestamp">VB.net SQL statement to query 1 yr old Timestamp</a> , my SQl query to look back a year of records gets stopped half way with the following error: <code>Select Error: ORA-01830: date format picture ends before converting entire input string</code>.</p>
  
  <p>Therefore, I decided to do a different route to rows that are not older than a year from current date.</p>
  
  <p>To do this I will make the following SELECT statement in VB.net:</p>
  
  <pre><code>Dim strSearch As String = "Select timestampVal from table_name WHERE timestampVal &gt; " &amp; minusYear &amp; " order by timestampVal DESC"
  </code></pre>
  
  <p>For my <code>minusYear</code> variable in my SELECT statement, I will first pull the following current date string:</p>
  
  <pre><code>Dim sign As String = DateTime.Now.ToString("yyyyMMdd-hhmmss")
  </code></pre>
  
  <p>However, to get <code>minusYear</code> I need to somehow minus a year from <code>sign</code>.</p>
  
  <p>I tried <code>Dim minusYear As String = DateTime.Now.AddYears(-1)</code>; however it formats it like so <code>MM\DD\YYYY HH:MI:SS PM</code> which won't work since I need to query where the string looks like <code>yyyyMMdd-hhmmss</code>.</p>
  
  <p><strong>Is there a way to simply minus 1 year from my sign string?</strong> I try to but there is of course datatype issues and converting the string to <code>CInt</code> doesn't really work.</p>
  
  <p>If I can get the 1 year minus sign to get <code>minusYear</code>, then my select statement works [I have tested it in SQL so this way will work, I just need to get <code>sign's</code> value minus a year]</p>