avvllvva Posted August 25, 2009 Share Posted August 25, 2009 hi, start_date & end_date are two columns in my table. how can I retrieve all the dates between these two date by using mysql query. is there any functions ? Quote Link to comment https://forums.phpfreaks.com/topic/171778-solved-mysql-days-retrival-from-two-dates/ Share on other sites More sharing options...
attock Posted August 25, 2009 Share Posted August 25, 2009 Try, http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Quote Link to comment https://forums.phpfreaks.com/topic/171778-solved-mysql-days-retrival-from-two-dates/#findComment-905789 Share on other sites More sharing options...
avvllvva Posted August 25, 2009 Author Share Posted August 25, 2009 actually my requirement is, I have a date as an input into the query, I want to check whether this date is between start_date & end_date. any ways? Quote Link to comment https://forums.phpfreaks.com/topic/171778-solved-mysql-days-retrival-from-two-dates/#findComment-905804 Share on other sites More sharing options...
gassaz Posted August 25, 2009 Share Posted August 25, 2009 Let me see... You want to check if a date it's between start_date & end_date.????? Quote Link to comment https://forums.phpfreaks.com/topic/171778-solved-mysql-days-retrival-from-two-dates/#findComment-906201 Share on other sites More sharing options...
xtopolis Posted August 26, 2009 Share Posted August 26, 2009 If the columns are of DATE/DATETIME/TIMESTAMP..etc type, shouldn't you be able to do a SELECT ... WHERE $queryDate BETWEEN startDate and endDate Quote Link to comment https://forums.phpfreaks.com/topic/171778-solved-mysql-days-retrival-from-two-dates/#findComment-906358 Share on other sites More sharing options...
suresh64633 Posted August 26, 2009 Share Posted August 26, 2009 You can try this: SELECT * FROM tblName WHERE $inuptDate BETWEEN $startDate AND $endDate Quote Link to comment https://forums.phpfreaks.com/topic/171778-solved-mysql-days-retrival-from-two-dates/#findComment-906433 Share on other sites More sharing options...
avvllvva Posted August 26, 2009 Author Share Posted August 26, 2009 Let me see... You want to check if a date it's between start_date & end_date.????? Yess Quote Link to comment https://forums.phpfreaks.com/topic/171778-solved-mysql-days-retrival-from-two-dates/#findComment-906441 Share on other sites More sharing options...
avvllvva Posted August 26, 2009 Author Share Posted August 26, 2009 If the columns are of DATE/DATETIME/TIMESTAMP..etc type, shouldn't you be able to do a SELECT ... WHERE $queryDate BETWEEN startDate and endDate So there is no other ways in mysql ? Quote Link to comment https://forums.phpfreaks.com/topic/171778-solved-mysql-days-retrival-from-two-dates/#findComment-906443 Share on other sites More sharing options...
avvllvva Posted August 26, 2009 Author Share Posted August 26, 2009 You can try this: SELECT * FROM tblName WHERE $inuptDate BETWEEN $startDate AND $endDate $startDate AND $endDate - they aren't variables, but columns Quote Link to comment https://forums.phpfreaks.com/topic/171778-solved-mysql-days-retrival-from-two-dates/#findComment-906444 Share on other sites More sharing options...
suresh64633 Posted August 26, 2009 Share Posted August 26, 2009 If the columns are of DATE/DATETIME/TIMESTAMP..etc type, shouldn't you be able to do a Than format it with DATE_FORMAT(date,format) in mysql AND If $startDate AND $endDate are columns only, you are right.Sorry for that Quote Link to comment https://forums.phpfreaks.com/topic/171778-solved-mysql-days-retrival-from-two-dates/#findComment-906473 Share on other sites More sharing options...
avvllvva Posted August 30, 2009 Author Share Posted August 30, 2009 Finally this works SELECT * FROM table WHERE '$inuptdate' BETWEEN col_startdate AND col_enddate by this I can check whether a input date is between two dates which r in different cols. Quote Link to comment https://forums.phpfreaks.com/topic/171778-solved-mysql-days-retrival-from-two-dates/#findComment-909158 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.