Click here to Skip to main content
15,891,902 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i tried following code..
quarry is working in Access, but not working in .net...


C#
public void fillcmbptraino()
       {
           da = new OleDbDataAdapter("SELECT tid FROM train WHERE dfdate > GETDATE", mycon);
           ds = new DataSet();
           da.Fill(ds);
           dt = ds.Tables[0];
           for (int i = 0; i < dt.Rows.Count; i++)
           {
               cmbptrain.Items.Add(dt.Rows[i].ItemArray[0]);

           }
       }





values in dfdate is
VB
dfdate
11/8/2011
1/8/2011
8/18/2011
8/25/2011


and datatype is Date/Time.



plz any one help me ..
thanks in advance....
Posted

It should be NOW().

OP: NOW() its only working for date..thatis not considering month or year

For Month & Year you have to check like below.
SELECT tid FROM train WHERE MONTH(dfdate) > MONTH(NOW())
SELECT tid FROM train WHERE YEAR(dfdate) > YEAR(NOW())


For more info check this[^].
 
Share this answer
 
v4
Comments
Ragi Gopi 4-Aug-11 5:08am    
sorry, not working ....
Toniyo Jackson 4-Aug-11 5:16am    
Are you getting any error?
Ragi Gopi 4-Aug-11 5:18am    
no...
but when i executed quarry wit GETDATE()in access it shows error..otherwise its working in access.
Toniyo Jackson 4-Aug-11 5:20am    
Check the updated answer
Ragi Gopi 4-Aug-11 5:27am    
Ya buddy its working ..thanks....
then wat happen to GETDATE....
=DateAdd("d", -10, [PromisedDate])
Displays a date that is 10 days before the value of the PromisedDate field.

=DateAdd("m", 1, "31-Jan-03")
Displays a date that is a month after 31-Jan-03, so the expression will evaluate to 28-Feb-03.
=DateAdd("m", 1, "31-Jan-04")

Displays a date that is a month after 31-Jan-04, and since 2004 is a leap year, the expression will evaluate to 29-Feb-04.
=DateAdd("q", 3, [PromisedDate])

Displays a date that is three quarters after the value of the PromisedDate field; for example, if the value of the PromisedDate field is 18-Jun-03, the expression will evaluate to 18-Mar-04.
=DateAdd("h", 3, [ArrivalTime])


Displays a time that is three hours after the value of the ArrivalTime field.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900