in reply to Perl's time and MySQL's timestamp
Moreover, MySQL has a large collection of date-oriented functions, which you should consider before burdening your client with tasks that should belong in the server.SELECT your_fields FROM your_table WHERE Timestamp_field BETWEEN "2003-02-01 10:30" AND "2003-02-05 12:00"
Having done that, you can easily compare fields coming from localtime with the ones coming from timestamps.#!/usr/bin/perl -w use strict; my ($sec,$min,$hour,$mday,$mon,$year) = localtime(1044436437); # Wed Feb 5 10:13:57 2003 $year += 1900; $mon++; my $timestamp = "20030205101357"; my ($tyear, $tmon, $tmday, $thour,$tmin, $tsec) = $timestamp =~ /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/; printf " Time Timestamp\n"; printf "year %4d %4d\n", $year, $tyear; printf "month %4d %4d\n", $mon, $tmon; printf "day %4d %4d\n", $mday, $tmday; printf "hour %4d %4d\n", $hour, $thour; printf "min %4d %4d\n", $min, $tmin; printf "sec %4d %4d\n", $sec, $tsec;
_ _ _ _ (_|| | |(_|>< _|
|
|---|