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

  • Home
  • SEARCH
  • 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 8256221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:47:24+00:00 2026-06-08T01:47:24+00:00

string month = DateTime.Now.Month.ToString(); string CommandText = SELECT slocref.slocname, partstuff.quantity, partstuff.currency, partstuff.postingdate + FROM

  • 0
string month = DateTime.Now.Month.ToString();
string CommandText = "SELECT slocref.slocname, partstuff.quantity, partstuff.currency, partstuff.postingdate" + " FROM partstuff INNER JOIN slocref ON partstuff.sloc = slocref.slocvalue";

This is the code to get date and month.

if (Regex.IsMatch(rdr["postingdate"].ToString(), "0" + month + "*"))
{
    if (rdr["slocname"].ToString() == "Answer/Slatwall")
    {
        string quantity = rdr["quantity"].ToString();
        string currency = rdr["currency"].ToString();
        answertotalmonth += float.Parse(currency);
        label100.Text = "$" + answertotalmonth.ToString("#,##0.00");
    }
}

This is just an example of the code that is run by the if statement.

But the if statement needs to get all of the July information and add it up. So from 07/01/2012 to 07/31/2012. I cannot change the SQL because it messes up the rest of the program. I tried to get the current date, add the 0 in front of it, then use a wildcard.

Need a little direction on this if statement.

Let me clarify this post. The “postingdate” value comes from FileHelpers. Importing a text file by fixed width into these values. The postingdate value looks like “07/16/12”

So, I want to get this current month, and then if a postingdate value has that month’s value, run the if statement code.

  • 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-08T01:47:26+00:00Added an answer on June 8, 2026 at 1:47 am

    Why would you do this?

     if (Regex.IsMatch(rdr["postingdate"].ToString(), "0" + month + "*"))
    

    If rdr[“postingdate”] is supposed to be a date, convert it to a date time and do a sensible comparison.

    if(DateTime.TryParse(rdr["postingdate"].ToString(), rdrDateTime))
    {
        // proceed as planned
        if (rdrDate.Month == DateTime.Now.Month) 
        {
           // and so on.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); string day = dt.DayOfWeek.ToString(); day = day.Substring(0,
I have the following code: string textTransDate = String.Format({0}-{1}-{2} {3}:{4}, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour,
I'm displaying a month name like this: String.Format({0:MMMM}, DateTime.Now) However, when using Swedish all
Okay, so I need something like this: time_span = 1.month date = DateTime.now date
Given the following code, how can I return some value (DateTime.Now.ToString()) if the exception
public readonly IEnumerable<string> PeriodToSelect = new string[] { MONTH }; var dataCollection = from
How do I get the current month as an integer, and as a string?
I need to generate a string of incrementing dates, something like this: (year, month,
I have a function that outputs an XML string: <expensesAC> <cashflow> <month>6</month> <cash>300</cash> <projected>null</projected>
here is code String[] month=new String[12]{January,February,March,April,May,June,July,August,September,Octomber,November,December}; int day = DateTime.Now.Day; int mon= DateTime.Now.Month; mon

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.