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 840713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:40:15+00:00 2026-05-15T05:40:15+00:00

This this code: SELECT SUBSTRING(posted,1,4) as year FROM styles reader = cmd1.ExecuteReader(CommandBehavior.CloseConnection); reader.Read(); Response.Write(reader[0].ToString());

  • 0

This this code:

SELECT SUBSTRING(posted,1,4) as year FROM styles
reader = cmd1.ExecuteReader(CommandBehavior.CloseConnection);
reader.Read();
Response.Write(reader[0].ToString());

I only get the string “System.Byte[]” printed out. How come?

If I use the software Mysql Query Browser I get the actual string from my database.

I understand that “Byte[]” is an arraylist but how do I convert this to a pure string?

The “posted”-field in my database contains a date like “2010-04-04 13:23:00” and I want to get only the year by using SUBSTRING.

  • 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-05-15T05:40:16+00:00Added an answer on May 15, 2026 at 5:40 am

    The correct query is

    SELECT DISTINCT SUBSTRING(CONVERT(varchar, posted, 111),1,4) as year FROM styles
    

    It equals to

    SELECT STR(YEAR(posted)) as year FROM styles-- YEAR returns int statement
    

    First argument is converted, than substring extracted.
    111 – the convertion format: http://www.mssqltips.com/tip.asp?tip=1145

    Also try

    reader["year"].ToString();
    

    as far as you use this alias.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 491k
  • Answers 491k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You should specify: private List<string> itemName; That way when you… May 16, 2026 at 10:07 am
  • Editorial Team
    Editorial Team added an answer for append on treview you should do rendererText = gtk.CellRendererText()… May 16, 2026 at 10:07 am
  • Editorial Team
    Editorial Team added an answer Sending large number of emails at once can really bog… May 16, 2026 at 10:07 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

This SELECT finds Kelly as expected: select [First Name], [Last Name], Phone from [Data$]
i have this code where you can select the date you like to attend
I had posted this earlier on Stack Overflow, but couldn't get a positive result.
This code basically translates characters based on position in one string to the character
Today I found this query in our code that pulls up a list of
I have been presented with this code. The code displays the title headings of
Okay. I have this code on my site: <?php session_start(); include database.php; include bruger.php;
I'm getting this error: Only parameterless constructors and initializers are supported in LINQ to
I have a website that grabs a random entry from a database and displays
i've been trying to figure out wh. sqy my object allocation keeps rigth up

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.