Consulting

Results 1 to 5 of 5

Thread: Solved: retrive date in sql or vb.6

  1. #1
    VBAX Contributor
    Joined
    May 2008
    Location
    bangalore
    Posts
    199
    Location

    Solved: retrive date in sql or vb.6

    i have date filed stored as nvarchar in sql server=
    joindate=20/10/2008
    relivingdate=
    i want to retive reliving date from joining date
    employee joining date is as below20th of October 2008
    ex
    if joining date is 20/10/2008 reliving date should be 19/10/2009 i.e one day before one year
    i want sql qurey to retrive the reliving date...
    or vb code..

  2. #2
    Evening Sham.

    In either, you can use:
    DateAdd Functions
    - Or -
    Month, Day, Year Functions

    Enjoy.
    Scott
    You don't understand anything until you learn it more than one way. ~Marvin Minsky

    I never teach my pupils; I only attempt to provide the conditions in which they can learn. - Albert Einstein

  3. #3
    VBAX Contributor
    Joined
    May 2008
    Location
    bangalore
    Posts
    199
    Location
    hi scott
    ya i used dayadd fynction



    SELECT DATEADD(Year, 1, 20-10-2007) AS NewDate i am able to increase the year but

    one day before ..how to do that.. ..

    it should display 19-10-2008



  4. #4
    Good Morning.

    You can either nest the DateAdd to add a year and subtract a day
    DateAdd("yyyy", 1, Date("d", -1, [JoinDate])) AS [NewDate]

    - OR -

    Take the number of days in a normal year and subtract 1.
    DateAdd("d", 364, [JoinDate]) AS [NewDate]

    Take care.
    Scott
    You don't understand anything until you learn it more than one way. ~Marvin Minsky

    I never teach my pupils; I only attempt to provide the conditions in which they can learn. - Albert Einstein

  5. #5
    VBAX Contributor
    Joined
    May 2008
    Location
    bangalore
    Posts
    199
    Location

    Thumbs up

    perfect,,,,

    thanks scott...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •