---
title: "System.Data.SqlClient.SqlException(Date_Format)"  
description: "System.Data.SqlClient.SqlException(Date_Format)"  
author: "Anonymous User"  
published: 2014-01-25  
updated: 2014-01-25  
canonical: https://www.mindstick.com/forum/1877/system-data-sqlclient-sqlexception-date_format  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# System.Data.SqlClient.SqlException(Date_Format)

I am using Sql-[Server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) 2012 and have a query

[string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) sqlQuery = "[SELECT distinct](https://www.mindstick.com/forum/34065/how-to-find-select-distinct-address-in-entity-framework) DATE_FORMAT(collectiondate,'%m/%d/%Y') FROM [reports](https://www.mindstick.com/blog/11576/magento-reports-extension) where patientid= " + patientId + " and isdeleted=false order by collectiondate desc";

var lst = Session.CreateSQLQuery(sqlQuery).List();

[ArrayList](https://www.mindstick.com/articles/11973/arraylist-class-in-c-sharp) rpt = new ArrayList();

rpt.Add("--ALL--");

but I am [getting an error](https://answers.mindstick.com/qa/95244/why-do-you-keep-getting-an-error-message-ox800ccc0b)

System.Data.SqlClient.SqlException: 'DATE_FORMAT' is not a recognized built-in [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) name.

Can [someone help me](https://answers.mindstick.com/qa/42311/can-someone-help-me-with-this-question-about-political-parties) out?

## Replies

### Reply by Pravesh Singh

Hi Lois,

You can use the FORMAT() command in SQL Server 2012 instead.

DECLARE @d DATETIME = GETDATE();

SELECT FORMAT(@d, 'mm/dd/yy', 'en-US') AS 'Result';


---

Original Source: https://www.mindstick.com/forum/1877/system-data-sqlclient-sqlexception-date_format

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
