If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > COUNT period btw 2 date time at SELECT statement

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-30-04, 02:53
winterain winterain is offline
Registered User
 
Join Date: Oct 2003
Posts: 22
Question 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 02:55.
Reply With Quote
  #2 (permalink)  
Old 03-30-04, 07:28
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
1. see CAST and CONVERT

2. see DATEDIFF
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 03-30-04, 19:22
winterain winterain is offline
Registered User
 
Join Date: Oct 2003
Posts: 22
Smile

Thanks very much!!!!!!!~^__^
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On