Convert VarChar to DateTime in SQL Server

Last Reply one year ago By Mudassar

Posted one year ago

Hello All, 

I Have database there i store value from datetime.now in date column but column have varchar datatype .

i want to get record last month to current date

but error convertin to varchar to datetime

please tell me how to convert varchar column to datetime to get record.

05/31/2018 10:45 AM

May 5 2018 10:45 AM

in this formate date inserted into logindate column and column data type is varchar so please tell me how to convert into date formate and get last 30 days data

thanks in advance

Posted one year ago

Use date format of SQL server if you need to perform operations like Last 30 days data, etc.

With Varchar it is not possible.

Secondly there is no reason to store formatted date in SQL when you can easily format and display on Page.