When I am converting a String Date to DateTime variable a timestamp is getting added and I am not sure how to remove that, I only need date. Please help!
The above expression is assigned to strDOS string variable
Here, Counter is a variable containing index.
Everything works fine till here.
Later when I assign string date to a DateTime variable using this: DateTime.ParseExact(StrDOS,formatconversion,System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat)
StrDos - Contains Date in string format
formatconversion - is date format ( yyyy/MM/dd)
So once this is applied time stamp is added. I want to get rid of time stamp. the variable should remain a DateTime as I am using it on Parameter to write it to SQL query.
Thanks lot @Srini84 and @ghazanfar , but I needed this for filtering rows on SQL,
SQL Query:
UPDATE dbo.TableName
SET Column1=0
WHERE MemberID='xxxx/' AND DateOfService='2021-05-22';
So if Date contains 2021-05-22 00:00:00 it will not match the clause. If anyone else has better solution it will be great. As it is known, to UPDATE data in SQL DB, the Data type passed from Variable should match with that of Column variable type on DB.
Say a column in DB table is of type DateTime , the variable using for Passing the value should alos be DateTime and Not a string.
Hope my question is clear. Thanks again for you all.
If anyone else has better solution to this, your help is appreciated.