converting text to date
Posted: Wed Feb 15, 2006 2:35 am
Pimptastic | Please use
**Note: PDATE = VARCHAR(7)
Please Advise
Pimptastic | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi,
I have a problem concerning a certain field in our database. When they created the table years ago, they made the field for the publication date a varchar format, instead of any date or datetime. The way info is put in is
01JAN05. Now i need to extract informationa ccording to this date, but the date is een as a text string, which makes my information wrong.
I dont know if STR_TO_DATE will really work for me, but if it will, how do i need to use it?
An example of the query (which does not produce the correct results):Code: Select all
$cfromdately1 = mktime(0, 0, 0, date("m") , 1, date("Y")-1);
$cfromdately1 = str_replace("-","",date("d-M-y",$cfromdately1));
$ctodately2 = $cfromdately1;Code: Select all
$sb2 = "select * from project.cprojinc where PDATE >= '$cfromdate2' AND PDATE < '$ctodate2' AND STARTED != 'Y'";
//echo "$sb2<br>";
$mb2 = mysql_query($sb2) or die("sb2 dies<br>$sb2");
$nb2 = mysql_num_rows($mb2);Please Advise
Pimptastic | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]