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 ? 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 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? 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.????? 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 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 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 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 ? 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 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 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. 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
Archived
This topic is now archived and is closed to further replies.