![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I am getting a field of date type from PostgreSQL and an integer that is a number of days (1 to 3). select date, num_days from table $date, $num_days In my perl script I am getting the current date #find current date ($mday,$mon,$year,$doy)=(localtime(time))[3..5,7]; $mon ++; $year +=1900; $today = "$year-$mon-$mday"; I need to test whether $date from PostgreSQL matches $today + $num_days. Can perl extract day of year ($doy) from the Postgres date? Is there a better way to do this? Thanks, Tom Hodges ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org |
#3
| |||
| |||
|
|
I am getting a field of date type from PostgreSQL and an integer that is a number of days (1 to 3). select date, num_days from table $date, $num_days In my perl script I am getting the current date #find current date ($mday,$mon,$year,$doy)=(localtime(time))[3..5,7]; $mon ++; $year +=1900; $today = "$year-$mon-$mday"; |
#4
| |||
| |||
|
|
hodges (AT) xprt (DOT) net wrote: I am getting a field of date type from PostgreSQL and an integer that is a number of days (1 to 3). select date, num_days from table $date, $num_days In my perl script I am getting the current date #find current date ($mday,$mon,$year,$doy)=(localtime(time))[3..5,7]; $mon ++; $year +=1900; $today = "$year-$mon-$mday"; I dont know about perl but Postgresql will do it for you as mypromt:#SELECT EXTRACT(DOY FROM DATE '2003-12-25') date_part ---------------------- 359 1 Row(s) affected Shoot back if this helps ! Regards, V Kashyap |
#5
| |||
| |||
|
|
and select extract( DOY FROM date) $sth = $dbh->prepare("SELECT date,address,time,host,direction,description, cal,reminder from firesides and select extract( DOY FROM date) where date > '$dstr1' and date <= '$dstr2'"); if ($sth->execute) { # assign each query record to an array $numrow = 0; while (($date,$address,$time,$host,$directions,$descript ion,$cal,$reminder, $db_doy) = $sth->fetc\ hrow) As per me the error is quite evident because it must be some thing |
#6
| |||
| |||
|
|
I have never used extract. This generates a syntax error when I added and select extract( DOY FROM date) |
|
$sth = $dbh->prepare("SELECT date,address,time,host,direction,description, cal,reminder from firesides and select extract( DOY FROM date) where date > '$dstr1' and date <= '$dstr2'"); |
#7
| |||
| |||
|
|
Is there a better way to do this? |
![]() |
| Thread Tools | |
| Display Modes | |
| |