Results 1 to 5 of 5

Thread: datesubtraction

  1. #1
    Join Date
    Feb 2012
    Posts
    16

    Unanswered: datesubtraction

    pls help me


    select CONVERT(VARCHAR(10), DATEADD(day,-1,'08/06/2012'),101),'08/06/2012' as dt

    No column name dt
    08/05/2012 08/06/2012 (this is in day month year format)

    i get the ans like this but i want ans like this


    07/06/2012 08/06/2012

  2. #2
    Join Date
    Apr 2012
    Posts
    213
    Try:

    Code:
    select CONVERT(VARCHAR(10), DATEADD(day,-1,'2012/06/08'),103), '08/06/2012' as dt
    Hope this helps.

  3. #3
    Join Date
    Feb 2012
    Posts
    16
    but I want to fetch the date from textbox
    like this
    select CONVERT(VARCHAR(10), DATEADD(day,-1,'"+textdate.text+"'),103), '08/06/2012' as dt


    I WANT (CONVERT(VARCHAR(10), DATEADD(day,-1,'"+textdate.text+"'),103)) THIS IN DD/MM/YYYY FORMAT

    PLS HELP ME
    Last edited by kannama; 06-07-12 at 02:46.

  4. #4
    Join Date
    Apr 2012
    Posts
    213
    I think it would be more correct to convert to DateTime in the application and use parameters.
    Anyway, experiment as follows:

    Code:
    select CONVERT(VARCHAR(10), DATEADD(day,-1, CONVERT(DATE, '08/06/2012', 103)), 103)
    Hope this helps.

  5. #5
    Join Date
    Feb 2012
    Posts
    16
    Thanku its working

Tags for this Thread

Posting Permissions

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