Hi
I have a Db2 data base in db2 the date and time stored including millisec.I want to get the data from DotNet C#. For comparing I have a data without milli sec.so i want to remove the millisec dta in db and compare .
This is my C# Query.
"SELECT " + "'(TIMESTAMP_FORMAT(StartDate,'YYYY-MM-DD HH24:MI:SS'))'"+ " FROM TableName where " + FirstName+ " = '" + fName + "'";
Can any one guide to get the result without Millisec.
Thanks
Convert Date time format
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Sachin Mandavkar38 pointsPosted Apr 16, 2014, 5:52 AM EDT
Try this
Replace your
Query ---------> (TIMESTAMP_FORMAT(StartDate,'YYYY-MM-DD HH24:MI:SS'))
and write like this
convert(datetime, convert(char(19), StartDate, 120))
OR
dateadd(millisecond, -datepart(millisecond, StartDate), StartDate)
srujana thallam50 pointsPosted Apr 16, 2014, 6:03 AM EDT
Thanks for your post.But again it will shows error,the query will not run.
I am trying run it in DB2