Re: perl - MySQL - date manipulation

  • From: "Octavian Rasnita" <orasnita@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 28 Oct 2008 12:46:10 +0200

Hi,

If you need to use a database, it is easier to use the database for 
calculations.

You can use:

current_date() + interval 30 day
or
current_date - interval 30 day
or
'2008-10-15' + interval 30 day;
or
current_date() + interval 1 month;

There are many date calculations you can use in MySQL which you can find more 
about in the MySQL manual.

Octavian

----- Original Message ----- 
From: "Lamar Upshaw" <lupshaw@xxxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Tuesday, October 28, 2008 12:29 PM
Subject: perl - MySQL - date manipulation


> I'm working with perl and MySQL for CGI scripting, and I need to be able to 
> calculate dates. How do I have MySQL calculate 30 days from now, and return 
> it to perl? Or, would it be easier to calculate 30 days from now in perl 
> instead? I understand how to get the present date and time in perl, but I 
> can't figure out how to calculate other dates. Truthfully, I'd rather do 
> this in MySQL and have it return to perl, because the calculated date will 
> be saved in a database table whether I calculate it using perl, or MySQL 
> anyway.
> 
> With All Respect,
> Upshaw, Lamar T 
> 
> __________
> View the list's information and change your settings at 
> //www.freelists.org/list/programmingblind
>
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: