Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27034

VS 2010 DateDiff in SQL Statement. Record Date and Date Now

$
0
0
Hi All,

I want to get the Days between Todays date i.e. 28/03/2013 and date on a (access db) record

Date column in Db is called "OrderDate" stored as date/time in dd/mm/yyy Format

vb.net Code:
  1. SQL5= "SELECT [ReturnOrder], datediff(day,[OrderDate],getdate()) FROM [Update]"
  2. 'both don't work
  3. SQL5= "SELECT [ReturnOrder], datediff(day,[OrderDate],getdate()) FROM [Update] GROUP by [ReturnOrder] ORDER BY datediff(day,[OrderDate],getdate())  DESC"
  4.  
  5.         da5 = New OleDb.OleDbDataAdapter(SQL5, con5)
  6.         da5.Fill(ds5, "Update")
  7.         dgvLeadtime.DataSource = ds5.Tables(0).DefaultView
  8.         con5.Close()

I was trying something like this but cant seem to get it working.

The end goal is to have a datagridview looks like

ReturnOrder ---------------------- DaysOutstanding
1929933 --------------------------------- 10
8727273 --------------------------------- 5

Can anyone help out here

Viewing all articles
Browse latest Browse all 27034

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>