|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How can i change varchar to datetimeI have a datetime column in db that stores datetime in varchar format suct
that "20060616120621". I want to get this date in a datetime format to make comparisions according to that. How can i do that with an SQL Query or c# code? Thanks You should call sql function to_date( string1, [ format_mask ], [
nls_language ] ) to convert a string to date format. Show quote "basulasz" <basul***@discussions.microsoft.com> wrote in message news:B46EE007-5894-42FC-B46D-275CAEA907FF@microsoft.com... >I have a datetime column in db that stores datetime in varchar format suct > that "20060616120621". I want to get this date in a datetime format to > make > comparisions according to that. How can i do that with an SQL Query or c# > code? > > Thanks "basulasz" <basul***@discussions.microsoft.com> wrote in message You don't indicate what kind of database you're using, but in Transact SQL news:B46EE007-5894-42FC-B46D-275CAEA907FF@microsoft.com... >I have a datetime column in db that stores datetime in varchar format suct > that "20060616120621". I want to get this date in a datetime format to > make > comparisions according to that. How can i do that with an SQL Query or c# > code? > > Thanks (for SQL Server), you can use CAST or CONVERT. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ca-co_2f3o.asp pvdg42 wrote:
Show quote > "basulasz" <basul***@discussions.microsoft.com> wrote in message On the .NET side, if you want to convert, use> news:B46EE007-5894-42FC-B46D-275CAEA907FF@microsoft.com... > >I have a datetime column in db that stores datetime in varchar format suct > > that "20060616120621". I want to get this date in a datetime format to > > make > > comparisions according to that. How can i do that with an SQL Query or c# > > code? > > > > Thanks > > You don't indicate what kind of database you're using, but in Transact SQL > (for SQL Server), you can use CAST or CONVERT. > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ca-co_2f3o.asp System.Convert.ToDateTime([date time string]) |
|||||||||||||||||||||||