terrypeck36 Posted December 19, 2006 Share Posted December 19, 2006 i have a query that is trying to compare the true(real) week ($week = date(W);)with the week of a date i am trying to pass into the mysql format_date function as a variable (itemdate - type int yyyymmdd) that is stored in a column.my query is :$sql = "SELECT * FROM table WHERE DATE_FORMAT('itemdate', '%U') = $week";its just not working it doesnt give me an error when i query the db either the value passed back is null so is this a valid way to handle date format??thanks for your time Link to comment https://forums.phpfreaks.com/topic/31186-solved-passing-a-variable-into-the-mysql-format_date-function/ Share on other sites More sharing options...
JasonLewis Posted December 19, 2006 Share Posted December 19, 2006 you do realise you are using %U in your query. try changing it to %W Link to comment https://forums.phpfreaks.com/topic/31186-solved-passing-a-variable-into-the-mysql-format_date-function/#findComment-144154 Share on other sites More sharing options...
terrypeck36 Posted December 19, 2006 Author Share Posted December 19, 2006 well date_format is a mysql function which takes in different parameters, these listed below are a few, i am using the w in my php date function to the get current weeki just dont know if its legitmate passing a variable through the msql date_format function %U Week (00..53), where Sunday is the first day of the week%u Week (00..53), where Monday is the first day of the week%V Week (01..53), where Sunday is the first day of the week; used with %X%v Week (01..53), where Monday is the first day of the week; used with %x%W Weekday name (Sunday..Saturday) Link to comment https://forums.phpfreaks.com/topic/31186-solved-passing-a-variable-into-the-mysql-format_date-function/#findComment-144166 Share on other sites More sharing options...
terrypeck36 Posted December 19, 2006 Author Share Posted December 19, 2006 my bad for wasting a thread i was passing in the variable as a string stupid me sorry all and thanks for your time Link to comment https://forums.phpfreaks.com/topic/31186-solved-passing-a-variable-into-the-mysql-format_date-function/#findComment-144175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.