Search the Community
Showing results for tags 'datetime'.
Sometimes if the database is not designed correctly you will find dates stored as text values. When trying to compare dates to text you will have problems and it's not efficient. So that's where the cast function comes in. Table: Invoice Field: InvoiceDate Data Set: 20080515 20081025 20070113 20091007 Expected Data Set: 05/15/2008 10/25/2008 01/13/2007 10/07/2009 To do this simply cast the field as a date: select cast(InvoiceDate as datetime) from Invoice