title: How to remove the time in my Date column when printing
body: <p>i have a program that print a datagridview and have a date column in it.</p>
  <p>the column display date only but when i try to print it, it will have time add how can i remove it?</p>
  <p>this is how it looks in the datagridview</p>
  <p><a href="https://i.stack.imgur.com/nKIk1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nKIk1.png" alt="enter image description here" /></a></p>
  <p>and this is my printpreview</p>
  <p><a href="https://i.stack.imgur.com/1MgGg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1MgGg.png" alt="enter image description here" /></a></p>
  <p>print code</p>
  <pre><code>        Try
              dgvInventoryLog.Columns(6).DefaultCellStyle.Format = &quot;dd/MM/yyyy&quot;
  
              Dim actualWidth As Integer = dgvInventoryLog.Columns.Cast(Of DataGridViewColumn).Sum(Function(c) c.Width)
              Dim percentage As Decimal = CDec(((100 / actualWidth) * e.MarginBounds.Width) / 100)
              Dim header As String = &quot;Inventory Log&quot;
              Dim footer As String
              Dim startX As Integer = e.MarginBounds.Left
              Dim startY As Integer = e.MarginBounds.Top
              Dim r As Rectangle
  
              Dim headerFont As New Font(dgvInventoryLog.Font.FontFamily, 15, FontStyle.Italic, GraphicsUnit.Pixel)
              Dim szf As SizeF = e.Graphics.MeasureString(header, headerFont)
              e.Graphics.DrawString(header, headerFont, Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width - szf.Width) / 2, startY - szf.Height)
              footer = &quot;Page &quot; &amp; pageCounter.ToString
              szf = e.Graphics.MeasureString(footer, headerFont)
              e.Graphics.DrawString(footer, headerFont, Brushes.Black, e.MarginBounds.Left + (e.MarginBounds.Width - szf.Width) / 2, e.MarginBounds.Bottom + 5)
  
              startY += 5
  
              'this is the text alignment
              Dim sf As New StringFormat
              sf.Alignment = StringAlignment.Center
              sf.LineAlignment = StringAlignment.Center
  
              Dim gridFont As New Font(dgvInventoryLog.Font.FontFamily, dgvInventoryLog.Font.Size, FontStyle.Regular, GraphicsUnit.Pixel)
  
              ' If startRow = 0 Then
              For x As Integer = 0 To dgvInventoryLog.Columns.Count - 1
                      r.X = startX
                      r.Y = startY
                      r.Width = CInt(dgvInventoryLog.Columns(x).Width * percentage)
                      r.Height = dgvInventoryLog.Rows(0).Height
                      e.Graphics.DrawRectangle(Pens.Black, r)
                      e.Graphics.DrawString(dgvInventoryLog.Columns(x).HeaderText, gridFont, Brushes.Black, r, sf)
                      startX += r.Width
                  Next
  
                  startY += r.Height
              ' End If
  
              For y As Integer = startRow To dgvInventoryLog.Rows.Count - 1
                  If y = dgvInventoryLog.NewRowIndex Then Continue For
                  startX = e.MarginBounds.Left
                  For x As Integer = 0 To dgvInventoryLog.Columns.Count - 1
                      r.X = startX
                      r.Y = startY
                      r.Width = CInt(dgvInventoryLog.Columns(x).Width * percentage)
                      r.Height = dgvInventoryLog.Rows(0).Height
                      e.Graphics.DrawRectangle(Pens.Black, r)
                      e.Graphics.DrawString(If(Not dgvInventoryLog.Rows(y).Cells(x).Value Is Nothing, dgvInventoryLog.Rows(y).Cells(x).Value.ToString, &quot;&quot;),
                                              gridFont, Brushes.Black, r, sf)
  
                      startX += r.Width
                  Next
                  startY += r.Height
                  If startY &gt;= e.MarginBounds.Bottom - 10 Then
                      If y &lt; dgvInventoryLog.Rows.Count - 1 Then
                          e.HasMorePages = True
                          pageCounter += 1
                          startRow = y + 1
                          Exit For
                      End If
                  End If
              Next
          Catch ex As Exception
              MessageBox.Show(ex.Message)
          End Try
  
      End Sub
  
  Private Sub btnPrint_Click(sender As Object, e As EventArgs) Handles btnPrint.Click
          ''preview button
          pageCounter = 1
          startRow = 0
          ppd.Document = pd
          ppd.WindowState = FormWindowState.Maximized
          ppd.ShowDialog()
      End Sub
  </code></pre>
  <pre><code>Private Sub getInventoryLog()
          Using conn As New OleDbConnection(&quot;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\INVENTORY_DB.accdb&quot;)
              Dim cmd As New OleDbCommand(&quot;Select ItemCode as [ITEM CODE], ItemName AS [ITEM NAME], Description AS [DESCRIPTION], Price AS [PRICE],
                                           Unit AS [UNIT], Quantity AS [QUANTITY], MovementDate AS [MOVEMENT DATE], `From` AS [FROM],
                                           `To` AS [TO] From [Items Movement]&quot;, conn)
              Dim da As New OleDbDataAdapter
              Dim dt As New DataTable
              da.SelectCommand = cmd
              dt.Clear()
              da.Fill(dt)
              dgvInventoryLog.Columns.Clear()
              dgvInventoryLog.DataSource = dt
  
              dgvInventoryLog.Columns(0).Width = 80
              dgvInventoryLog.Columns(1).Width = 250
              dgvInventoryLog.Columns(2).Width = 150
              dgvInventoryLog.Columns(3).Width = 70
              dgvInventoryLog.Columns(4).Width = 70
              dgvInventoryLog.Columns(5).Width = 100
              dgvInventoryLog.Columns(6).Width = 110
              dgvInventoryLog.Columns(7).Width = 135
              dgvInventoryLog.Columns(8).Width = 135
  
          End Using
      End Sub
  </code></pre>
  <p>this is where i get the code for printing. i dont quite understand it, but its working just fine so i just copy paste it, so if that is where i messed up i will be grateful for pointing it out for me. thanks</p>
  <p><a href="https://www.vbforums.com/showthread.php?872037-RESOLVED-Need-help-with-printing-datagridview-content" rel="nofollow noreferrer">https://www.vbforums.com/showthread.php?872037-RESOLVED-Need-help-with-printing-datagridview-content</a></p>