Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2003

    Talking Unanswered: asking for SQL query

    i am developing a account statement so when the user click on the link to view the February link it will show the transaction from Jan - Feb ,
    how to format it to a query
    i have the sample fo the following table:

    ID trans_desc trans_date
    1 testing 1/9/2003 11:33:00 AM
    2 testing1 2/9/2003 11:33:00 AM
    3 testing2 1/9/2004 11:33:00 AM

    how to i extract the transaction description month from the month Jan-Feb . how to i do for the SQL query

  2. #2
    Join Date
    Jun 2003
    Provided Answers: 1
    If there are 50 people on this forum, you'll get 50 different ways to do this. Here is one:

    declare @SelectedDate datetime
    set @SelectedDate = '2003-02-15'

    select *
    from YourTable
    where trans_date >= convert(char(4), @SelectedDate, 120)+'-01-01'
    and trans_date < dateadd(month, 1, convert(char(7), @SelectedDate, 120)+'-01')
    If it's not practically useful, then it's practically useless.

    blindman "sqlblindman"

Posting Permissions

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