I tried searching for solutions to my problem and I have been stuck for two hours now. ("HH:mm:ss") īut it's telling me that it's a method which is not valid for given context. Or string sqlFormattedDate = ("yyyy-MM-dd") + " " + Definition and Usage The CONVERT () function converts a value (of any type) into a specified datatype. So I tried doing this to my code as per my research here in StackOverflow: string sqlFormattedDate = ("yyyy-MM-dd") + " " + ("HH:mm:ss") Īnd suggested I need to parse. The output on date is okay, but time is always "12:00:00" so I changed my code to the following: string sqlFormattedDate = ("yyyy-MM-dd") + " " + String sqlFormattedDate = ("yyyy-MM-dd HH:mm:ss") This was my first code: DateTime myDateTime = DateTime.Now I am trying to save the current date time format from C# and convert it to an SQL Server date format like so yyyy-MM-dd HH:mm:ss so I can use it for my UPDATE query. Conclusion How to Convert Date to String with the CONVERT () Function The CONVERT () function expects two arguments: the date has to be a string, or with built-in date getters like NOW () or SYSDATE () the data type the type of data you want to convert the date to.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |