getting the date as a folder name
-
hi everyone
set rsdate=conn.execute("select dateentered from mtallotment where id=" & request.querystring("id")) if not rsdate.eof then DateFolder=month(rsdate(0)) & "" & day(rsdate(0)) & "" & year(rsdate(0)) end if
the above code is written previously by my senior for asp page the same task i want to do in c#.net. in this code i am getting date from the database table and checking for the folder with date as a name of the folder i want create a variable with folder name as date from database table (eg: date:10/14/2007 ---->foldername:10142007) awaiting for u responses regards -
hi everyone
set rsdate=conn.execute("select dateentered from mtallotment where id=" & request.querystring("id")) if not rsdate.eof then DateFolder=month(rsdate(0)) & "" & day(rsdate(0)) & "" & year(rsdate(0)) end if
the above code is written previously by my senior for asp page the same task i want to do in c#.net. in this code i am getting date from the database table and checking for the folder with date as a name of the folder i want create a variable with folder name as date from database table (eg: date:10/14/2007 ---->foldername:10142007) awaiting for u responses regardssunilwise wrote:
DateFolder=month(rsdate(0)) & "" & day(rsdate(0)) & "" & year(rsdate(0))
This line can be translated as this:
DateTime dt = DateTime.Parse(rsdate);
string FolderName = String.Format("{0}{1}{2}",dt.Month,dt.Day,dt.Year);Hope it helps.
I will use Google before asking dumb questions
-
sunilwise wrote:
DateFolder=month(rsdate(0)) & "" & day(rsdate(0)) & "" & year(rsdate(0))
This line can be translated as this:
DateTime dt = DateTime.Parse(rsdate);
string FolderName = String.Format("{0}{1}{2}",dt.Month,dt.Day,dt.Year);Hope it helps.
I will use Google before asking dumb questions
thanx for u r reply Mr.Andrei Ungureanu its workin fine;);):)
-
hi everyone
set rsdate=conn.execute("select dateentered from mtallotment where id=" & request.querystring("id")) if not rsdate.eof then DateFolder=month(rsdate(0)) & "" & day(rsdate(0)) & "" & year(rsdate(0)) end if
the above code is written previously by my senior for asp page the same task i want to do in c#.net. in this code i am getting date from the database table and checking for the folder with date as a name of the folder i want create a variable with folder name as date from database table (eg: date:10/14/2007 ---->foldername:10142007) awaiting for u responses regardsThat is not a good way to format the date, as different dates will share the same folder. For example, the dates 2007-01-11 and 2007-11-01 will both become "1112007". If you really need to create that format anyway, you can use .ToString("Mdyyyy") to format a date that way. A better format would be "MMddyyyy", as that would give a unique value for each date, so 2007-01-11 becomes "01112007" and 2007-11-01 becomes "11012007". An ever better format would be to follow the ISO 8601 order "yyyyMMdd". This is unambigous (as opposed to the dd/MM/yyyy and MM/dd/yyyy formats), and you even get the folders in date order in the explorer. :)
Experience is the sum of all the mistakes you have done.