ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Query to convert VARCHAR to DATETIME in SQL Server<p>Hi <a class="username" rel="Kirron"> Kirron</a>,</p> <p>Refer below test query.</p> <p><strong><span style="text-decoration: underline;">SQL</span></strong></p> <pre class="brush: sql">DECLARE @Test AS TABLE(Bill_No INT,Name VARCHAR(50),TotalAmount DECIMAL(10,2),Date VARCHAR(10)) INSERT INTO @Test VALUES(13,&#39;Lakshmi Devi Jatra Mahotsava&#39;,&#39;500.00&#39;,&#39;08-07-2018&#39;) INSERT INTO @Test VALUES(14,&#39;Chandru Kmatagi&#39;,&#39;1800.00&#39;,&#39;08-07-2018&#39;) INSERT INTO @Test VALUES(15,&#39;Nurani Shedaji&#39;,&#39;780.00&#39;,&#39;08-07-2018&#39;) INSERT INTO @Test VALUES(15,&#39;Nurani Shedaji&#39;,&#39;780.00&#39;,&#39;08-07-2018&#39;) INSERT INTO @Test VALUES(16,&#39;Design Charge&#39;,&#39;500.00&#39;,&#39;08-07-2018&#39;) INSERT INTO @Test VALUES(17,&#39;Arun&#39;,&#39;90.00&#39;,&#39;08-07-2018&#39;) INSERT INTO @Test VALUES(70,&#39;Honnutagi Banner&#39;,&#39;900.00&#39;,&#39;08-08-2018&#39;) INSERT INTO @Test VALUES(71,&#39;B.L.D.E College&#39;,&#39;720.00&#39;,&#39;08-08-2018&#39;) SELECT * FROM @Test WHERE DATEPART(MONTH,CONVERT(DATETIME,Date,103)) = DATEPART(MONTH,GETDATE())</pre> <p><strong><span style="text-decoration: underline;">Output</span></strong></p> <table border="1"> <tbody> <tr> <td>Bill_No</td> <td>Name</td> <td>TotalAmount</td> <td>Date</td> </tr> <tr> <td>70</td> <td>Honnutagi Banner</td> <td>900.00</td> <td>08-08-2018</td> </tr> <tr> <td>71</td> <td>B.L.D.E College</td> <td>720.00</td> <td>08-08-2018</td> </tr> </tbody> </table>https://www.aspforums.net:443/Threads/966244/Query-to-convert-VARCHAR-to-DATETIME-in-SQL-Server/https://www.aspforums.net:443/Threads/966244/Query-to-convert-VARCHAR-to-DATETIME-in-SQL-Server/Mon, 13 Aug 2018 00:15:12 GMT