Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8242345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:08:11+00:00 2026-06-07T21:08:11+00:00

My dates are varchar(50) and appear like this in my database: 2/15/2012 The table

  • 0

My dates are varchar(50) and appear like this in my database:

2/15/2012

The table looks like this: (Note: someid is not a primary key, its identifies a group)

 |  someid  |   date     |  float_value  | 
 |   1      | 2/15/2012  |     3.2       |   
 |   1      | 2/15/2012  |     1.4       |
 |   1      | 2/15/2012  |     2.1       |
 |   1      | 2/16/2012  |     1.8       |

How would I do something like this:

select avg(date), avg(float_value)
where someid = 1

To return something like this:

|  date     |  float_value  |
| 2/15/2012 |   2.126       |     

Perhaps the answer isn’t average date, but like the date the occurs the most often (in terms of the someid).

Any help would be appreciated from the sql experts.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T21:08:13+00:00Added an answer on June 7, 2026 at 9:08 pm

    Forget the float nonsense. How about:

    SELECT DATEADD(DAY, AVG(DATEDIFF(DAY, 0, create_date)), 0) FROM sys.objects;
    

    In your case you’ll need to convert first. E.g.

    SELECT 
      avg_date = DATEADD(DAY, AVG(DATEDIFF(DAY, 0, CONVERT(SMALLDATETIME, [date]))), 0) 
    FROM dbo.yourtable
    WHERE someid = 1;
    

    This variation may also be useful:

    SELECT 
      someid, 
      avg_date = DATEADD(DAY, AVG(DATEDIFF(DAY, 0, CONVERT(SMALLDATETIME, [date]))), 0) 
    FROM dbo.yourtable
    GROUP BY someid;
    

    EDIT to present the exact precise and particular formatting that seems to be necessary:

    SELECT 
      avg_date = CONVERT(CHAR(10), 
        DATEADD(DAY, AVG(DATEDIFF(DAY, 0, CONVERT(SMALLDATETIME, [date]))), 0),
        101) 
    FROM dbo.yourtable
    WHERE someid = 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NOTE: I'm using EF 4.2 with Database First Method and DbContext. This is NOT
With a table created using this SQL Create Table X ( ID varchar(4) Not
I have a VARCHAR field in mysql with dates separated by commas. Like this:
I have this table: CREATE TABLE `table1` ( `object` varchar(255) NOT NULL, `score` decimal(10,3)
i have come across a mysql database which has dates entered in a varchar
With this table: CREATE TABLE test_insert ( col1 INT, col2 VARCHAR(10), col3 DATE )
i would like to select * from table where dates between (some_date and another_date)
I'm trying to get the dates out of this varchar(512) column: CAM; Initial period
I have several dates stored as varchar in the following format: 01-01-2012 I want
Im working on a database that store dates in a varchar(10) mysql field (so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.