Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. getting the date as a folder name

getting the date as a folder name

Scheduled Pinned Locked Moved C#
csharpdatabase
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sunil Wise
    wrote on last edited by
    #1

    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

    A G 2 Replies Last reply
    0
    • S Sunil Wise

      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

      A Offline
      A Offline
      Andrei Ungureanu
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • A Andrei Ungureanu

        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

        S Offline
        S Offline
        Sunil Wise
        wrote on last edited by
        #3

        thanx for u r reply Mr.Andrei Ungureanu its workin fine;);):)

        1 Reply Last reply
        0
        • S Sunil Wise

          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

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          That 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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups