Date conversion

Discussion in 'ASP .Net' started by Piotr Karwatka, Nov 11, 2004.

  1. Hi!

    I have a little problem - i have an integer value with contain a number of
    some day in current day (for example 56) - and my problem is - how can i
    caonvert this integer value to DateTime (for example 33 = 02.02.2004)? I
    want to reverse function to DateTime.DaysOfYear

    Thanks

    --
    Pozdrawiam serdecznie!

    --
    Piotr Karwatka
    -- ,
    -- http://amigo.pop.pl
     
    Piotr Karwatka, Nov 11, 2004
    #1
    1. Advertising

  2. Piotr Karwatka

    Shiva Guest

    May be like this?

    // C#
    DateTime x = new DateTime (DateTime.Now.Year, 1, 1);
    x = x.AddDays (<your day count>-1);
    // x now holds DateTime for <your day count>

    "Piotr Karwatka" <> wrote in message
    news:cmvrrp$geb$...
    Hi!

    I have a little problem - i have an integer value with contain a number of
    some day in current day (for example 56) - and my problem is - how can i
    caonvert this integer value to DateTime (for example 33 = 02.02.2004)? I
    want to reverse function to DateTime.DaysOfYear

    Thanks

    --
    Pozdrawiam serdecznie!

    --
    Piotr Karwatka
    -- ,
    -- http://amigo.pop.pl
     
    Shiva, Nov 11, 2004
    #2
    1. Advertising

  3. Piotr Karwatka

    Hans Kesting Guest

    Piotr Karwatka wrote:
    > Hi!
    >
    > I have a little problem - i have an integer value with contain a
    > number of some day in current day (for example 56) - and my problem
    > is - how can i caonvert this integer value to DateTime (for example
    > 33 = 02.02.2004)? I want to reverse function to DateTime.DaysOfYear
    >
    > Thanks
    >
    > --
    > Pozdrawiam serdecznie!


    How about this
    - start with jan 1st of your year
    - add (number-1) days

    public DateTime ReverseDaysOfYear(int year, int days)
    {
    DateTime dt = new DateTime(year, 1, 1);
    dt = dt.AddDays(days-1);
    return dt;
    }


    Hans Kesting
     
    Hans Kesting, Nov 11, 2004
    #3
  4. Time interval is represenred by TimeSpan structure. You can create a
    timespan for the number of days you need and than add it to an instance of
    DateTime structure preset to to the beginning of the year.

    Eliyahu

    "Piotr Karwatka" <> wrote in message
    news:cmvrrp$geb$...
    > Hi!
    >
    > I have a little problem - i have an integer value with contain a number

    of
    > some day in current day (for example 56) - and my problem is - how can i
    > caonvert this integer value to DateTime (for example 33 = 02.02.2004)? I
    > want to reverse function to DateTime.DaysOfYear
    >
    > Thanks
    >
    > --
    > Pozdrawiam serdecznie!
    >
    > --
    > Piotr Karwatka
    > -- ,
    > -- http://amigo.pop.pl
    >
    >
     
    Eliyahu Goldin, Nov 11, 2004
    #4
  5. Thanks! That's that what i was looking for!

    U¿ytkownik "Shiva" <> napisa³ w wiadomo¶ci
    news:OPgOBo$...
    > May be like this?
    >
    > // C#
    > DateTime x = new DateTime (DateTime.Now.Year, 1, 1);
    > x = x.AddDays (<your day count>-1);
    > // x now holds DateTime for <your day count>
    >
    > "Piotr Karwatka" <> wrote in message
    > news:cmvrrp$geb$...
    > Hi!
    >
    > I have a little problem - i have an integer value with contain a number
    > of
    > some day in current day (for example 56) - and my problem is - how can i
    > caonvert this integer value to DateTime (for example 33 = 02.02.2004)? I
    > want to reverse function to DateTime.DaysOfYear
    >
    > Thanks
    >
    > --
    > Pozdrawiam serdecznie!
    >
    > --
    > Piotr Karwatka
    > -- ,
    > -- http://amigo.pop.pl
    >
    >
    >
     
    Piotr Karwatka, Nov 11, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    619
    Matthew Speed
    Nov 8, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,303
    Michael Borgwardt
    May 30, 2004
  3. Matt
    Replies:
    2
    Views:
    534
    Pete Becker
    Nov 8, 2003
  4. Matt
    Replies:
    3
    Views:
    735
    Richard Heathfield
    Nov 8, 2003
  5. Sanjeeb
    Replies:
    2
    Views:
    186
Loading...

Share This Page