• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

SQL Statement help...

azuro

n00b
Joined
Dec 14, 2002
Messages
62
Let say i have a table:

Create Table records(
Name char(20),
Date char(20),
Primary Key (Name));

Date is in format 2005/07/13
If I want to query the database and retrieve data that have date between 2005/06/12 and 2005/07/12, how can I do it with regular expression?

For the Date attribute, if the datatype is Timestamp instead, how would I do it? Thanks.
BTW, I'm using postgresql and programming it with perl.
 
if I use the date column, how do I find the records between 2 dates?
Will the following perl code works?

$date1 = "2005/11/12";
$date2 = "2005/12/22";

$sth = $dbh->prepare( q{
SELECT name
FROM records
WHERE date >= ? AND date <= ?
})

$rc = $sth->execute($date1, $date2);
 
I will naively assume that you're using PHP or a similar language in conjunction with your SQL.

If that's the case, PHP has a built in function (date()) that, when passed the proper parameters, will take a standard calendar date and return the UNIX time stamp (which is strictly in seconds). So, all you need to do is convert both dates and then do a simple comparison.

http://us2.php.net/manual/en/function.date.php
 
Back
Top