Skip to content
Advertisement

how to take average for Varchar data type

one of my column in my table is of type varchar. which contains hexadecimal values. i need to take average for particular month . the below is my query. please help me how to change the code to achieve it.

Thanks in advance

Advertisement

Answer

You can use CAST to DateTime

CAST

For example

The filed should be a DateTime string or they will be error

EDIT

A small example for you.

The keyPoint is command.ExecuteReader() get the SQL Query Collection.

SqlCommand

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement