473,382 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

get month and date on label in Format '7/07'

parshupooja
159 100+
Hello,

Can anyone help in getting month and year in this format '12/07' or 6/07 on a label. I am using asp.net C#
Please don't misunderstand the format its not mm/yy or 07/07. its just m/yy

any help will be appreciated
Aug 17 '07 #1
6 1947
nateraaaa
663 Expert 512MB
Hello,

Can anyone help in getting month and year in this format '12/07' or 6/07 on a label. I am using asp.net C#
Please don't misunderstand the format its not mm/yy or 07/07. its just m/yy

any help will be appreciated
You should be able to use the DateTime object to get the required data. The DateTime object has a Month and Year property. The Month property should print a single numeric month without a leading zero. If it does not just check to see if the Month starts with 0 then remove it using string.Replace or string.Substring. The Year property will return a 4 digit year. You will need to use string.Replace or string.Substring to get the last 2 digits of the year.

Nathan
Aug 17 '07 #2
cmrhema
375 256MB
You should be able to use the DateTime object to get the required data. The DateTime object has a Month and Year property. The Month property should print a single numeric month without a leading zero. If it does not just check to see if the Month starts with 0 then remove it using string.Replace or string.Substring. The Year property will return a 4 digit year. You will need to use string.Replace or string.Substring to get the last 2 digits of the year.

Nathan
i have used current date and transfered it to text box
you choose your relevant date and pass it to label
textBox1.Text = DateTime.Now.ToString("M/yy");
Aug 18 '07 #3
parshupooja
159 100+
Thank Youuuuuuuuuuuu,
I got it
Aug 20 '07 #4
nateraaaa
663 Expert 512MB
Thank Youuuuuuuuuuuu,
I got it
What was the code that you used?
Aug 20 '07 #5
parshupooja
159 100+
sorry I should have mentioned a code I used
Here it is
Expand|Select|Wrap|Line Numbers
  1. string mon = DateTime.Now.Month.ToString();
  2.         string year = DateTime.Now.Year.ToString();
  3.         string cyear = year.Substring(year.Length - 2, 2);
  4.         lblqtr.Text = mon + "/" + cyear;
  5.  
  6.         string pmon = DateTime.Now.AddMonths(-1).Month.ToString();
  7.         string pyear = DateTime.Now.Year.ToString();
  8.         string Pyear = pyear.Substring(pyear.Length - 2, 2);
  9.         lblpqtr.Text = pmon + "/" + Pyear;
  10.  
Aug 20 '07 #6
Plater
7,872 Expert 4TB
The
Expand|Select|Wrap|Line Numbers
  1. DateTime.Now.ToString("M/yy");
  2.  
would be a more simple solution, but what you got does work.
Aug 20 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Finlay | last post by:
Hi Group I am designing a report that should show a meter reading for each month and the previous meter reading for the previous month. The months are text stored in a field tMonth. The...
13
by: jm | last post by:
I am trying to use datepart to get the real name of the month like "April" or "APR" not just "4." I could not find it in the documentation. Sorry. Thank you.
6
by: Tony Miller | last post by:
All I have an aggregate query using the function Month & Year on a datereceived field ie: TheYear: Year() TheMonth: Month() These are the group by fields to give me a Count on another field by...
4
by: Anon | last post by:
Hello All! I have written a simple app that auto downloads a file from a secure ftp, renames it, and moves it to a network location. Everything works great except the renaming part. I parse out...
6
by: Burghew | last post by:
Hello, I generate invoices for my customers evry month. I want to keep a form which will allow the user to select the Month and Year through a combo and thus generate reports based on the month...
2
by: troddy | last post by:
I am using the DatePart funtion in a query to extract the day, month and year in separate fields in a query. The function works fine but I am only getting a number for the month even if the field...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
4
by: perryclisbee via AccessMonster.com | last post by:
I have dates of service for several people that range all over each month. ie: patient had dates of service of: 7/3/2006, 7/24/2006 and 7/25/2006. I need to create a new field via a query that...
6
by: Zeba | last post by:
Hi, I have a page with a calendar and two datalist items - one containing month values and the other, year values. Depending on the month/year value chosen ( in text/string format ) I should be...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.