Click here to Skip to main content
15,906,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all,
i do have a requirement that to pass datetime in 24 hour format to a storedprocedure in sql server.
for that i have written as follows:-
DateTime fromdate=DateTime.Now;
DateTime todate=DateTime.Now.AddDays(-5);
these are giving o/p as
8-06-2015 12:00:00 and 3-06-2015 12:00:00
But i need to pass to an stored procedure as
2015-06-08 00:00:01 and 2015-06-03 23:59:59
i have searched many sites but unable to find exact matching to my requirement plz help me solve this....
Thanks in Advance.
Posted
Updated 7-Jun-15 20:39pm
v2

You have a basic mistake about date/time...You think for some reason that date/time is what you see, but actually date/time is a binary value stored exactly the same but formatted for display differently...
So when you want to sore date/time in SQL choose the proper data type for the column (and NOT! string) and pass the date/time as is (binary) - SQL will take care of the rest!!!
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Jun-15 4:07am    
Sure, a 5.
—SA
Kornfeld Eliyahu Peter 8-Jun-15 4:09am    
Thank you...
Check out these solutions to a similar question just a few days ago => Confused about using SQL data type[^]
 
Share this answer
 
v2

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