locked
DateAdd(dd, - day(getdate()),getdate()) to VB.net RRS feed

  • Question

  • User-458875980 posted

    SQL - DateAdd(dd, - day(getdate()),getdate())

    need to convert this into VB.net

     

    Thanks,

    Rajesh G

    Wednesday, March 14, 2012 9:46 AM

Answers

  • User551462331 posted

    try this

    using  Microsoft.VisualBasic

    DateTime dtNew = DateAdd(DateInterval.Day, DateTime.Now.Day-(DateTime.Now.Day*2), DateTime.Now);

    hope this helps...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 14, 2012 9:55 AM

All replies

  • User1935975665 posted

    Not sure I understood the sql statement but if you're trying to get last day of the previous month I think this works.

    DateAndTime.DateAdd(DateInterval.Day, -DateAndTime.Today.Day, Today)

    Wednesday, March 14, 2012 9:53 AM
  • User551462331 posted

    try this

    using  Microsoft.VisualBasic

    DateTime dtNew = DateAdd(DateInterval.Day, DateTime.Now.Day-(DateTime.Now.Day*2), DateTime.Now);

    hope this helps...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 14, 2012 9:55 AM
  • User533502567 posted

    SQL - DateAdd(dd, - day(getdate()),getdate())

    Like this..

                DateTime dt = DateTime.Now;
                dt = dt.AddDays(-(dt.Day));
    Wednesday, March 14, 2012 9:55 AM