Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    22

    Question Unanswered: COUNT period btw 2 date time at SELECT statement

    I hv a datetime field named "datejoin" in table "leave".

    String sqlleave = "SELECT convert(char(10), datejoin, 121) AS datejoin1 FROM leave WHERE lstaffid=?";

    1.RESULT is in yyyy-mm-dd format (eg : 2004-03-30).
    How can I format it into dd-mm-yyyy?

    2.After this, I have to count the period(how many days) btw "datejoin" and "getDate", which getDATE is current date.
    Any IDEA to do this function??? This function no need format the datetime, only run the code to get the number of days.

    Please and thanks very much~~
    Last edited by winterain; 03-30-04 at 03:55.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    1. see CAST and CONVERT

    2. see DATEDIFF
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2003
    Posts
    22

    Smile

    Thanks very much!!!!!!!~^__^

Posting Permissions

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