Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
'FORMAT' is not a recognized built-in function name.

 string queryStr = "SELECT Category,ItemID,FORMAT(DateFrom 'dd/MM/yyyy'), FORMAT(DateTo, 'dd/MM/yyyy'), FROM Donation Order By ItemID,Category ";
Posted

Hi,

Use Convert function instead. Format function is not a valid function here.

Your code should look something like this:
SQL
string queryStr = "SELECT Category,ItemID,CONVERT(VARCHAR(10), DateFrom, 103), CONVERT(VARCHAR(10), DateTo, 103), FROM Donation Order By ItemID,Category ";

Value 103 means format to dd/mm/yyyy. More information here: SQL Server CONVERT() Function[^]
 
Share this answer
 
v2
try this it's may be help,
C#
string queryStr = "SELECT Category,ItemID,'" + Convert.ToDateTime("'columnName'").ToShortDateString() + "','" + Convert.ToDateTime("'anotherColumnName'").ToShortDateString() + "' FROM Donation Order By ItemID,Category ";


hit to reply for any query
 
Share this answer
 

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