I have a string variable
Dim SHG As String
SHG = "FILENAME" + "_" + "Jan12"
Here the File name is constant and the Jan12 is not a fixed one.
Here i want to increament this to 13,14,15.. and etc and same as month also like jan,feb,march,april,may,june,july,aug .... dec
how can i increament thie and store in a variable.
Jan12,Feb12...,Jan13,Feb13...
Post Solution for this post
Thanks in advance
Loading
Jignesh TrivediPosted Feb 29, 2012, 7:23 AM
so try this..
int startYear = 2005;
int currentYear = DateTime.Now.Year;
for (var y = startYear; y <= currentYear; y++)
{
DateTime date = new DateTime(y, 1, 1);
string year = y.ToString().Substring(2, 2);
for (var r = 1; r <= 12; r++)
{
Console.WriteLine("FILENAME_" + date.ToString("MMM") + year);
date = date.AddMonths(1);
}
}
hope this ans of que.
Rajkumar RPosted Feb 29, 2012, 7:10 AM
Jignesh TrivediPosted Feb 29, 2012, 6:09 AM
Try this...
string year = DateTime.Now.Year.ToString().Substring(2, 2);
DateTime date = new DateTime(1900, 1, 1);
for (var r = 1; r <= 12; r++)
{
Console.WriteLine("FILENAME_" + date.ToString("MMM") + year);
date = date.AddMonths(1);
}
this code is work for only current year. i.e. 2012
but que is year is start from where?
hope this help.
Rajkumar RPosted Feb 29, 2012, 5:45 AM
Jignesh TrivediPosted Feb 29, 2012, 5:37 AM
I have Few que on Requirement.
1) up to what number you want to increament ?
2) what is business logic?
VulpesPosted Feb 29, 2012, 5:35 AM