locked
datediff RRS feed

  • Question

  • User-1345623911 posted

    i have a smalldatetime field in the db called "date_created"

    i want to set a new label in my datalist until for ex 7 days after that date

    how can i do that?

    i guess i should use the datediff function but i don't know how

    please write me the code

    Sunday, September 23, 2007 6:49 PM

Answers

  • User-1509636757 posted

    vb.net code please!
     

    Dim Now As DateTime = DateTime.Now
    Dim NowPlus7 As DateTime = Now.AddDays(7)

     

    how can i add 7 days to my date field

    now.addDays(7) adds 7 days to the time now

     


    Dim NowPlus7 As DateTime = dtDateCreatedFieldValue.AddDays(7) '....here assume that dtDateCreatedFieldValue holds the value of date_Created Field

    Label1.Text = NowPlus7.ToString();

     

     

    Good Luck./. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 24, 2007 4:02 AM

All replies

  • User187056398 posted

    The DateTime type has what you need:

        DateTime Now = DateTime.Now;
        DateTime NowPlus7 = Now.AddDays(7);
    
     
    Sunday, September 23, 2007 9:27 PM
  • User-1345623911 posted

    vb.net code please!

    ok i am a little confused

    how can i add 7 days to my date field

    now.addDays(7) adds 7 days to the time now

    should i compare it to the time now??

    Monday, September 24, 2007 3:41 AM
  • User-1509636757 posted

    vb.net code please!
     

    Dim Now As DateTime = DateTime.Now
    Dim NowPlus7 As DateTime = Now.AddDays(7)

     

    how can i add 7 days to my date field

    now.addDays(7) adds 7 days to the time now

     


    Dim NowPlus7 As DateTime = dtDateCreatedFieldValue.AddDays(7) '....here assume that dtDateCreatedFieldValue holds the value of date_Created Field

    Label1.Text = NowPlus7.ToString();

     

     

    Good Luck./. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 24, 2007 4:02 AM
  • User-524191788 posted

     I need some help!

     

    I've two text boxes for starting date and ending date, these dates are in dd/mm/yy format. Result should display on lbldiff.text

     Ex:

     

    Starting Date: 01/04/2008

     Ending Date: 016/04/2008

     

    Result: 15 days

     

    If it is more than 30 or 31 days then it should display 1 month and 15 days something like this, If it is more than a year then it should display 1 Year, 4 months 14 days.

     

    I hope you can solve this problem

     

    Thanks in advance. 


     

    Sunday, May 11, 2008 10:46 AM