convert C# datetime to sql server datetime

jassie

Well-known member
Joined
Nov 13, 2012
Messages
61
Programming Experience
1-3
In a C# 2010 desktop application I am using a linq to sql statement to compare a C# datetime field to a sql server 2008 r2 datetime field. By doing this comparison I am getting inconsistent results. Thus I am guessing a C# datetime field is not the same as a sql server 2008 r2 datetime value.
Thus for this comparison to work, I would like to know how to change a C# datetime field to a sql server date time field. I would think I would need to do this conversion prior to comparing the dates.
Thus now you show me code and/or point me to a reference that will show me how to solve this problem?
 
There is no conversion necessary. If it's not working then you're just doing it wrong. Show us what you're doing and tell us what behaviour you expect to see and what you actually and we can probably tell you what's wrong with it.
 
You are correct that I am not getting the results I want.
I want to compare to see if sql date > minimum date (1/1/1753) and sql date < current today's date. Can you tell me how to write this comparision?
 
Back
Top Bottom