In C# code I want to do a date comparison against a column is the database.
Something like:
select someColumn from someTable
where CurrentDate-someDate > ElapsedTimeColumn
I want to get the currentdate in C# and run a query from my application.
How do i get the format of:
mm/dd/yyyy hh:ss:mm AM/PM
Thanks.
|
Go4Expert Founder
|
![]() |
| 4Aug2007,12:41 | #2 |
|
DateTime class located in the System namespace would help you.
Code:
System.DateTime.Now System.DateTime.Today |
|
Go4Expert Member
|
|
| 7Aug2007,19:19 | #3 |
|
Any idea what system.datetime.now would throw an sql exception error?
The format it returns is identical to the format of my sql column.... This isn't an issue, and I decided to just use the sql function getdate to do what I needed, but I do no understand why this would throw an error. Perhaps it is a simple formatting error on my part when concatenating the strings, but maybe someone had a similiar problem before. thanks. |
|
Newbie Member
|
|
| 1Jun2010,22:04 | #4 |
|
This scenario usually arises when the data is not 'received' properly from the database.
Check this link ( shahriarnk.com/Shahriar-N-K-Research-Embedding-SQL-in-C-Sharp-Java.html ) for details on how to connect to SQL Server database from C#.NET database applications as well as Java database applications. It also describes how to pass embedded SQL queries, calling stored procedures, pass parameters etc. Shahriar Nour Khondokar: shahriarnk.com/ |

